vyperlang / vyper

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

bug: ternary expression with `self` or environment variables fails at codegen #3507

Open tserg opened 1 year ago

tserg commented 1 year ago

Version Information

What's your issue about?

This contract fails to compile with an AssertionError - (isinstance(contract_address.typ, InterfaceT)) in ir_for_external_call.

Note: In case this exmaple is valid Vyper syntax, one would need to be careful as several analysis and sanity checks (e.g circularity checks) rely on the fact that function calls are always on the form self.FUNC_NAME.

@external
def foo():
    (self if True else self).bar()

@internal
def bar():
    pass

This contract fails to compile with vyper.exceptions.TypeCheckFailure: Name node did not produce IR.

@external
def foo():
    a: Bytes[10] = (msg if True else msg).data

h/t @trocher

How can it be fixed?

Fill this in if you know how to fix it.

trocher commented 6 months ago

Because the first example now compiles, the following results in vyper.exceptions.CodegenPanic: unhandled exception None, parse_Attribute

@external
def foo():
    x:uint256 = (self if True else self).balance
charles-cooper commented 6 months ago

yea, i'm not sure it should compile, it just happens to typecheck (which is arguably a bug)