Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

type conversions should be represented explicitly in the AST #3580

Open
0xalpharush opened this issue Aug 30, 2023 · 0 comments
Open

type conversions should be represented explicitly in the AST #3580

0xalpharush opened this issue Aug 30, 2023 · 0 comments

Comments

@0xalpharush
Copy link

Version Information

  • vyper Version (output of vyper --version): 0.3.7
  • OS: osx
  • Python Version (output of python --version): 3.11

What's your issue about?

The conversion of x to Test is represented as a Call and must be handle specially as Test is not a function name but rather an interface. Instead, there should be a type conversion node that converts x to type Test. Additionally, the Hex literal 0x0000000000000000000000000000000000000000 should have have a type conversion to address as it could also be bytes20. Representing these semantics explicitly will increase the accuracy of tools that attempt to model Vyper's semantics faithfully.

interface Test:
    def foo() -> (int128, uint256): nonpayable

@internal
def foo() -> (int128, int128):
    return 2, 3

@external
def bar():
    a: int128 = 0
    b: int128 = 0
    (a, b) = self.foo()

    x: address = 0x0000000000000000000000000000000000000000
    c: uint256 = 0
    a, c = Test(x).foo()

How can it be fixed?

Create explicit type conversion nodes in the AST

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant