Cannot implicitly convert

def bla(x: UInt) -> UInt:
    return x * 2
def laber(x: UInt) -> UInt:
    return x / 10

def main():
    print(bla(3))
    print(laber(10))

fails with

bla.mojo:4:14: error: cannot implicitly convert ‘SIMD[float64, 1]’ value to ‘UInt’

Is this expected?

This is expected (and consistent with Python, at least).

The issue is that x / 10 results in a Float64, you might want to use x // 10.

1 Like

Thanks. :man_facepalming:

It should be noted that SIMD integer types do not share this behaviour and work as you had expected

def laber(x: Int64) -> Int64:
    return x / 10

def main():
    print(laber(10))
2 Likes