vyper
vyper copied to clipboard
constant evaluation of min, max builtins fails for literals outside int128 range
Version Information
- vyper Version (output of
vyper --version): v0.3.1
What's your issue about?
vyper.exceptions.TypeMismatch: Cannot perform action between dislike numeric types
contract "tmp/typecheck.vy", function "foo", line 4:11
3 # 2**129 == 680564733841876926926749214863536422912
---> 4 return min(-1, 680564733841876926926749214863536422912)
------------------^
5
How can it be fixed?
https://github.com/vyperlang/vyper/blob/a90f645cf4110fe630f0f99fee51dcbb99d34e1c/vyper/builtin_functions/functions.py#L1701-L1702
the issue is with the negative int right? min(1, 2**129) compiles, while min(-1, 55) doesn't (v0.3.6+commit.4a2124d)
vyper.exceptions.InvalidType: Expected uint256 but literal can only be cast as int104 or int96
contract "foo.vy", function "foo", line 5:11
4 # 2**125 == 42535295865117307932921825928971026432
---> 5 return min(-1, 55)
------------------^
6
Also, what's the idea behind this?: https://github.com/vyperlang/vyper/blob/d85cf2aebd9fe7919d895a3b6e3cf5c46f04b3ef/vyper/builtin_functions/functions.py#L2008
I believe this was fixed by #3288 itself fixing a dup of this issue (#3284) @charles-cooper
can confirm this works