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

Raise clearer exception when using a yet undeclared variable in a type annotation #3215

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 5 additions & 1 deletion vyper/semantics/analysis/utils.py
Expand Up @@ -307,7 +307,11 @@ def types_from_List(self, node):
def types_from_Name(self, node):
# variable name, e.g. `foo`
name = node.id
if name not in self.namespace and name in self.namespace["self"].typ.members:
if (
name not in self.namespace
and "self" in self.namespace
and name in self.namespace["self"].typ.members
):
raise InvalidReference(
f"'{name}' is a storage variable, access it as self.{name}", node
)
Expand Down