Skip to content

Commit

Permalink
fix: ensure all index_multiple methods have the same signature
Browse files Browse the repository at this point in the history
  • Loading branch information
achidlow committed Mar 26, 2024
1 parent a9c7600 commit 0c93a47
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 13 deletions.
10 changes: 5 additions & 5 deletions src/puya/awst_build/eb/arc4/arrays.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,9 @@

class DynamicArrayGenericClassExpressionBuilder(GenericClassExpressionBuilder):
def index_multiple(
self, index: Sequence[ExpressionBuilder | Literal], location: SourceLocation
self, indexes: Sequence[ExpressionBuilder | Literal], location: SourceLocation
) -> TypeClassExpressionBuilder:
match index:
match indexes:
case [TypeClassExpressionBuilder() as eb]:
element_wtype = eb.produces()
wtype = wtypes.ARC4DynamicArray.from_element_type(element_wtype)
Expand Down Expand Up @@ -144,9 +144,9 @@ def produces(self) -> wtypes.WType:

class StaticArrayGenericClassExpressionBuilder(GenericClassExpressionBuilder):
def index_multiple(
self, index: Sequence[ExpressionBuilder | Literal], location: SourceLocation
self, indexes: Sequence[ExpressionBuilder | Literal], location: SourceLocation
) -> TypeClassExpressionBuilder:
match index:
match indexes:
case [TypeClassExpressionBuilder() as item_type, array_size]:
array_size_ = get_integer_literal_value(array_size, "Array size")
element_wtype = item_type.produces()
Expand Down Expand Up @@ -285,7 +285,7 @@ def call(
)

def index_multiple(
self, index: Sequence[ExpressionBuilder | Literal], location: SourceLocation
self, indexes: Sequence[ExpressionBuilder | Literal], location: SourceLocation
) -> ExpressionBuilder:
raise CodeError(
"Address does not support type arguments",
Expand Down
6 changes: 3 additions & 3 deletions src/puya/awst_build/eb/arc4/numeric.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,12 +134,12 @@ def check_bitsize(self, n: int, location: SourceLocation) -> None:

class _UFixedNxMClassExpressionBuilder(NumericARC4ClassExpressionBuilder):
def index_multiple(
self, index: Sequence[ExpressionBuilder | Literal], location: SourceLocation
self, indexes: Sequence[ExpressionBuilder | Literal], location: SourceLocation
) -> ExpressionBuilder:
try:
scale_expr, precision_expr = index
scale_expr, precision_expr = indexes
except ValueError as ex:
raise CodeError(f"Expected two type arguments, got {len(index)}", location) from ex
raise CodeError(f"Expected two type arguments, got {len(indexes)}", location) from ex
n = get_integer_literal_value(scale_expr, "UFixedNxM scale")
m = get_integer_literal_value(precision_expr, "UFixedNxM precision")

Expand Down
4 changes: 2 additions & 2 deletions src/puya/awst_build/eb/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ def index(
raise CodeError(f"{self._type_description} does not support indexing", location)

def index_multiple(
self, index: Sequence[ExpressionBuilder | Literal], location: SourceLocation
self, indexes: Sequence[ExpressionBuilder | Literal], location: SourceLocation
) -> ExpressionBuilder:
"""Handle self[index]"""
raise CodeError(f"{self._type_description} does not support multiple indexing", location)
Expand Down Expand Up @@ -342,7 +342,7 @@ def index(

@abc.abstractmethod
def index_multiple(
self, index: Sequence[ExpressionBuilder | Literal], location: SourceLocation
self, indexes: Sequence[ExpressionBuilder | Literal], location: SourceLocation
) -> TypeClassExpressionBuilder:
...

Expand Down
4 changes: 2 additions & 2 deletions src/puya/awst_build/eb/template_variables.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@

class GenericTemplateVariableExpressionBuilder(IntermediateExpressionBuilder):
def index_multiple(
self, index: Sequence[ExpressionBuilder | Literal], location: SourceLocation
self, indexes: Sequence[ExpressionBuilder | Literal], location: SourceLocation
) -> ExpressionBuilder:
match index:
match indexes:
case [TypeClassExpressionBuilder() as eb]:
wtype = eb.produces()
case _:
Expand Down
2 changes: 1 addition & 1 deletion src/puya/awst_build/subroutine.py
Original file line number Diff line number Diff line change
Expand Up @@ -1031,7 +1031,7 @@ def visit_index_expr(self, expr: mypy.nodes.IndexExpr) -> ExpressionBuilder | Li
)
case mypy.nodes.TupleExpr(items=items):
args = [item.accept(self) for item in items]
return base_expr.index_multiple(index=args, location=expr_location)
return base_expr.index_multiple(indexes=args, location=expr_location)

index_expr_or_literal = expr.index.accept(self)
return base_expr.index(index=index_expr_or_literal, location=expr_location)
Expand Down

0 comments on commit 0c93a47

Please sign in to comment.