Skip to content

Commit

Permalink
feat: Allow mutable tuple items to be updated
Browse files Browse the repository at this point in the history
  • Loading branch information
tristanmenzel authored and achidlow committed Mar 26, 2024
1 parent b482ebe commit 8ea6ed5
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/puya/ir/builder/arc4.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
ValueTuple,
)
from puya.ir.types_ import AVMBytesEncoding
from puya.ir.utils import format_tuple_index
from puya.parse import SourceLocation
from puya.utils import bits_to_bytes

Expand Down Expand Up @@ -1180,7 +1181,18 @@ def handle_arc4_assign(
),
source_location=source_location,
)
case awst_nodes.TupleItemExpression(
base=awst_nodes.VarExpression(wtype=wtypes.WTuple(types=items_types)) as base_expr,
index=index_value,
) if not items_types[index_value].immutable:
(result,) = assign(
context=context,
names=[(format_tuple_index(base_expr.name, index_value), source_location)],
source=value,
source_location=source_location,
)

return result
case _:
raise CodeError("Not a valid assignment target", source_location)

Expand Down

0 comments on commit 8ea6ed5

Please sign in to comment.