Skip to content

Commit

Permalink
minor refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
achidlow committed Feb 7, 2025
1 parent 502d663 commit 0b3e759
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
7 changes: 3 additions & 4 deletions src/puyapy/awst_build/eb/array.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ def __init__(self, typ: pytypes.PyType, location: SourceLocation):
assert typ.generic == pytypes.GenericArrayType
wtype = typ.wtype
assert isinstance(wtype, wtypes.WArray)
assert not wtype.immutable
self._wtype = wtype
super().__init__(typ, location)

Expand All @@ -85,10 +86,8 @@ def call(
) -> InstanceBuilder:
typ = self.produces()
values = tuple(expect.argument_of_type_else_dummy(a, typ.items).resolve() for a in args)
wtype = typ.wtype
assert isinstance(wtype, wtypes.WArray)
return ArrayExpressionBuilder(
NewArray(values=values, wtype=wtype, source_location=location), self._pytype
NewArray(values=values, wtype=self._wtype, source_location=location), typ
)


Expand Down Expand Up @@ -263,7 +262,7 @@ def call(
ArrayConcat(
left=NewArray(wtype=imm_wtype, values=[], source_location=location),
right=self.expr,
wtype=imm_type.wtype,
wtype=imm_wtype,
source_location=location,
),
)
Expand Down
5 changes: 2 additions & 3 deletions src/puyapy/awst_build/eb/immutable_array.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ def __init__(self, typ: pytypes.PyType, location: SourceLocation):
assert typ.generic == pytypes.GenericImmutableArrayType
wtype = typ.wtype
assert isinstance(wtype, wtypes.WArray)
assert wtype.immutable
self._wtype = wtype
super().__init__(typ, location)

Expand All @@ -83,10 +84,8 @@ def call(
) -> InstanceBuilder:
typ = self.produces()
values = tuple(expect.argument_of_type_else_dummy(a, typ.items).resolve() for a in args)
wtype = typ.wtype
assert isinstance(wtype, wtypes.WArray)
return ImmutableArrayExpressionBuilder(
NewArray(values=values, wtype=wtype, source_location=location), self._pytype
NewArray(values=values, wtype=self._wtype, source_location=location), self._pytype
)


Expand Down

0 comments on commit 0b3e759

Please sign in to comment.