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

fix[lang]: fix validation of public variable export #4375

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion vyper/semantics/analysis/module.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
)
from vyper.semantics.data_locations import DataLocation
from vyper.semantics.namespace import Namespace, get_namespace, override_global_namespace
from vyper.semantics.types import EventT, FlagT, InterfaceT, StructT
from vyper.semantics.types import TYPE_T, EventT, FlagT, InterfaceT, StructT
from vyper.semantics.types.function import ContractFunctionT
from vyper.semantics.types.module import ModuleT
from vyper.semantics.types.utils import type_from_annotation
Expand Down 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