Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
tserg committed Jul 21, 2023
1 parent 0003db0 commit b56e806
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions vyper/semantics/analysis/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,21 +184,26 @@ def types_from_Attribute(self, node):
# variable attribute, e.g. `foo.bar`
t = self.get_exact_type_from_node(node.value, include_type_exprs=True)
name = node.attr

def _raise_invalid_reference(name, node):
raise InvalidReference(
f"'{name}' is not a storage variable, it should not be prepended with self", node
)

try:
s = t.get_member(name, node)
if isinstance(s, VyperType):
# ex. foo.bar(). bar() is a ContractFunctionT
return [s]
if is_self_reference and (s.is_constant or s.is_immutable):
raise InvalidReference(
f"'{name}' is not a storage variable, it should not be prepended with self",
node,
)
_raise_invalid_reference(name, node)
# general case. s is a VarInfo, e.g. self.foo
return [s.typ]
except UnknownAttribute:
if not is_self_reference:
raise
if name in self.namespace:
_raise_invalid_reference(name, node)

suggestions_str = get_levenshtein_error_suggestions(name, t.members, 0.4)
raise UndeclaredDefinition(
Expand Down

0 comments on commit b56e806

Please sign in to comment.