Open tserg opened 1 year ago
Other example:
@external
@payable
def foo():
x:uint256 = 1
a:uint256 = min([1,2][x], 1)
vyper.exceptions.TypeMismatch: Given reference has type int8, expected uint256
(Also for reference still an issue as of 0.3.10)
note: several of these are resolved as of v0.4.0b1 (b53a020c74857de33cf4fd1a6d24a398539758b1) but some still will not compile.
Version Information
vyper --version
): https://github.com/vyperlang/vyper/commit/9e3b9a2b8ae55aa83b5450080f750be15f819de7python --version
): 3.10.4What's your issue about?
Builtin functions whose return type depends on some of its argument's type can be incorrectly typed resulting in the compiler exiting with a
TypeMismatch
.To trigger this behavior, call the builtin function with arguments such that:
get_possible_types_from_node
should return multiple potential types for this arguments on which the return type of the builtin function depends.Affected builtins:
min
andmax
:a: uint256 = min(1 if True else 2, 1)
a: uint256 = unsafe_add(1 if True else 2, 1)
shift
(deprecated as of v0.3.8):a: uint256 = shift(-1, 1 if True else 2)
uint2str
:f: String[12] = uint2str(1 if True else 2)
h/t @trocher
How can it be fixed?
Fill this in if you know how to fix it.