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

calls and references to state variables should not be represented as Attribute nodes #3582

Open
0xalpharush opened this issue Sep 1, 2023 · 1 comment

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?

Another improvement to the Vyper AST would be disambiguating calls and references to state variables from accesses to field of structure types. This is something that Solidity has done poorly and it creates a lot of complexity in the AST especially as the language has evolved and expressions like X.Y can represent a whole host of constructs. Below is an example of several instances of this in Vyper. In order to resolve shadowing like self.caller = caller, it requires keeping track of context like the namespace is self rather than just explicitly distinguishing that this is a reference to a state variable. Accessing attributes of self like balance and address could also be made distinct from variables or fields by creating a unique representation in the AST. This eliminates a lot of special casing, branching, and other complexities required in consumers of the AST by representing precisely info the Vyper has already gathered during compilation.

interface X:
    pass

caller: address
@external
def __default__():
     caller: addres = msg.sender
     self.caller = caller
     amt: uint256 = self.balance
     where: address = X(self).address

How can it be fixed?

Make field access distinct from referring to state variables or calls like SELFBALANCE and ADDRESS

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

2 participants