From ef7bffc2798cc4ba20ac289b237c1d54a4efefb0 Mon Sep 17 00:00:00 2001 From: tserg <8017125+tserg@users.noreply.github.com> Date: Mon, 30 Jan 2023 17:38:09 +0800 Subject: [PATCH 1/3] set name for helper --- vyper/semantics/types/user.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/vyper/semantics/types/user.py b/vyper/semantics/types/user.py index 926ac09245..8fcd5e270e 100644 --- a/vyper/semantics/types/user.py +++ b/vyper/semantics/types/user.py @@ -55,6 +55,9 @@ def __init__(self, name: str, members: dict) -> None: # also conveniently checks well-formedness of the members namespace self._helper = VyperType(members) + # set the name for exception handling in `get_member` + self._helper._id = name + def get_type_member(self, key: str, node: vy_ast.VyperNode) -> "VyperType": self._helper.get_member(key, node) return self From b686c4cde3e56a811241ee55d99091d4842a8b21 Mon Sep 17 00:00:00 2001 From: tserg <8017125+tserg@users.noreply.github.com> Date: Mon, 30 Jan 2023 17:38:16 +0800 Subject: [PATCH 2/3] add test --- tests/parser/syntax/test_enum.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/tests/parser/syntax/test_enum.py b/tests/parser/syntax/test_enum.py index fe7b9fc83d..8a008a1af5 100644 --- a/tests/parser/syntax/test_enum.py +++ b/tests/parser/syntax/test_enum.py @@ -7,6 +7,7 @@ NamespaceCollision, StructureException, TypeMismatch, + UnknownAttribute, ) fail_list = [ @@ -97,6 +98,18 @@ def foo():nonpayable """, EnumDeclarationException, ), + ( + """ +enum Roles: + ADMIN + USER + +@external +def foo() -> Roles: + return Roles.GUEST + """, + UnknownAttribute, + ) ] From e570464b4800e0ec109255544a9c251b22062925 Mon Sep 17 00:00:00 2001 From: tserg <8017125+tserg@users.noreply.github.com> Date: Mon, 30 Jan 2023 18:35:25 +0800 Subject: [PATCH 3/3] fix lint --- tests/parser/syntax/test_enum.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/parser/syntax/test_enum.py b/tests/parser/syntax/test_enum.py index 8a008a1af5..c13f27f497 100644 --- a/tests/parser/syntax/test_enum.py +++ b/tests/parser/syntax/test_enum.py @@ -109,7 +109,7 @@ def foo() -> Roles: return Roles.GUEST """, UnknownAttribute, - ) + ), ]