mojo icon indicating copy to clipboard operation
mojo copied to clipboard

[BUG] `object` does not implement `__truediv__` or `__floordiv__`

Open Brian-M-J opened this issue 10 months ago • 2 comments

Bug description

When running the code snippets linked below in the Mojo Playground, I get the following errors:

__floordiv__ code:

/source/prog.mojo:2:20: error: 'object' does not implement the '__floordiv__' method
    return (x + y) // 2
           ~~~~~~~ ^
mojo: error: failed to parse the provided Mojo

It is supposed to print 1

__truediv__ code:

/source/prog.mojo:2:20: error: 'object' does not implement the '__truediv__' method
    return (x + y) / 2
           ~~~~~~~ ^
mojo: error: failed to parse the provided Mojo

It is supposed to print 1.5

I consider this to be a bug as the exact same code works perfectly fine in Python.

Steps to reproduce

  • Include relevant code snippet or link to code that did not work as expected.

__truediv__ code

__floordiv__ code

Just run the above snippets in the Playground.

System information

I ran this on the Mojo Playground as of 06-04-2024.

Brian-M-J avatar Apr 06 '24 16:04 Brian-M-J