Skip to content

Commit 0cee75f

Browse files
committed
fix _as_tuple_member def and usage
1 parent 4cd509b commit 0cee75f

File tree

3 files changed

+13
-0
lines changed

3 files changed

+13
-0
lines changed

vyper/semantics/types/base.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,10 @@ class VyperType:
5050
The name of the type.
5151
_as_array: bool, optional
5252
If `True`, this type can be used as the base member for an array.
53+
_as_hashmap_key: bool, optional
54+
If `True`, this type can be used as a hashmap key
55+
_as_tuple_member: bool, optional
56+
If `True`, this type can be used as a tuple member
5357
_valid_literal : Tuple
5458
A tuple of Vyper ast classes that may be assigned this type.
5559
_invalid_locations : Tuple
@@ -78,6 +82,8 @@ class VyperType:
7882

7983
_as_array: bool = False # rename to something like can_be_array_member
8084
_as_hashmap_key: bool = False
85+
_as_tuple_member: bool = True # can be a tuple member
86+
8187

8288
_supports_external_calls: bool = False
8389
_attribute_in_annotation: bool = False

vyper/semantics/types/subscriptable.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -330,6 +330,9 @@ class TupleT(VyperType):
330330

331331
def __init__(self, member_types: Tuple[VyperType, ...]) -> None:
332332
super().__init__()
333+
for mt in member_types:
334+
if not mt._as_tuple_member:
335+
raise StructureException(f"not a valid tuple member: {mt}")
333336
self.member_types = member_types
334337
self.key_type = UINT256_T # API Compatibility
335338

vyper/semantics/types/user.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -337,6 +337,10 @@ class StructT(_UserType):
337337
def __init__(self, _id, members, ast_def=None):
338338
super().__init__(members)
339339

340+
for mt in members.values():
341+
if not mt._as_tuple_member:
342+
raise StructureException(f"not a valid struct member: {mt}")
343+
340344
self._id = _id
341345

342346
self.ast_def = ast_def

0 commit comments

Comments
 (0)