Skip to content

Commit

Permalink
Test round-trip TypeSpec values (#519)
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonpaulos committed Aug 31, 2022
1 parent a66907e commit 5231083
Show file tree
Hide file tree
Showing 3 changed files with 370 additions and 274 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Unreleased

## Fixed
* Subroutines annotated with a `TupleX` class are now invoked with an instance of that exact class, instead of the more general `Tuple` class ([#519](https://github.com/algorand/pyteal/pull/519))

# 0.17.0

## Added
Expand Down
16 changes: 15 additions & 1 deletion pyteal/ast/abi/tuple.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,21 @@ def length_static(self) -> int:
return len(self.value_specs)

def new_instance(self) -> "Tuple":
return Tuple(self)
match self.length_static():
case 0:
return Tuple0()
case 1:
return Tuple1(self)
case 2:
return Tuple2(self)
case 3:
return Tuple3(self)
case 4:
return Tuple4(self)
case 5:
return Tuple5(self)
case _:
return Tuple(self)

def annotation_type(self) -> "type[Tuple]":
vtses = self.value_type_specs()
Expand Down

0 comments on commit 5231083

Please sign in to comment.