Skip to content

Commit

Permalink
fix[lang]: fix validation of public variable export
Browse files Browse the repository at this point in the history
this commit fixes validation of exporting public variables from `self`.
raise a proper exception instead of panicking.
  • Loading branch information
charles-cooper committed Nov 25, 2024
1 parent 8f433f8 commit 0e16b89
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions vyper/semantics/analysis/module.py
Original file line number Diff line number Diff line change
Expand Up @@ -497,6 +497,16 @@ def visit_ExportsDecl(self, node):
decl = info.var_info.decl_node
if not info.var_info.is_public:
raise StructureException("not a public variable!", decl, item)
# e.g. self.foo_variable
if not isinstance(item, vy_ast.Attribute) or not isinstance(
get_expr_info(item.value).typ, (ModuleT, TYPE_T)
):
raise StructureException(
"invalid export of a value",
item.value,
hint="exports should look like <module>.<function | interface>",
)

funcs = [decl._expanded_getter._metadata["func_type"]]
elif isinstance(info.typ, ContractFunctionT):
# regular function
Expand Down

0 comments on commit 0e16b89

Please sign in to comment.