vyperlang / vyper

Pythonic Smart Contract Language for the EVM
https://vyperlang.org
Other
4.83k stars 789 forks source link

Compiler gives incorrect arithmetic hint for decimal division #4077

Closed ritzdorf closed 1 week ago

ritzdorf commented 3 months ago

Version Information

Issue description

When encountering a decimal division / the compiler gives a hint on how the code should look. However, sometimes it gives incorrect hint, as it seems to drop important parentheses.

POC

# pragma version 0.4.0.rc3

@external
def foo(a: uint256, b:uint256, c: uint256) -> uint256:
    return (a + b) / c 

The compiler suggests:

  (hint: did you mean `a + b // c`?)

which is not correct.