diff --git a/pyteal/ast/abi/type.py b/pyteal/ast/abi/type.py index da3dc5bbc..b7ebe5bd5 100644 --- a/pyteal/ast/abi/type.py +++ b/pyteal/ast/abi/type.py @@ -90,7 +90,10 @@ def __init__(self, spec: TypeSpec) -> None: assert proto.mem_layout local_types = proto.mem_layout.local_stack_types - if len(local_types) < 128: + # NOTE: you can have at most 128 local variables. + # len(local_types) + 1 computes the resulting length, + # should be <= 128 + if len(local_types) + 1 <= 128: local_types.append(self._type_spec.storage_type()) self._stored_value = FrameVar(proto, len(local_types) - 1) return