Skip to content

Commit

Permalink
fix: resolves some bugs with match statements (#25)
Browse files Browse the repository at this point in the history
  • Loading branch information
achidlow authored Dec 12, 2023
1 parent c21dd34 commit 2c7de55
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "puya"
version = "0.1.2"
version = "0.1.3"
description = "An optimising Python to TEAL compiler"
authors = ["Algorand Foundation <contact@algorand.foundation>"]
readme = "README.md"
Expand Down
2 changes: 1 addition & 1 deletion src/puya/ir/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,7 @@ class Switch(ControlOp):

@cases.validator
def _check_cases(self, _attribute: object, cases: dict[Value, BasicBlock]) -> None:
if any(case.atype != self.value.atype for case in cases):
if not all(case.atype & self.value.atype for case in cases):
raise CodeError(
"Switch cases types mismatch with value to match", self.source_location
)
Expand Down
3 changes: 2 additions & 1 deletion src/puya/ir/optimize/constant_propagation.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from puya.ir.models import Assignment, Intrinsic
from puya.ir.ssa import TrivialPhiRemover
from puya.ir.visitor_mutator import IRMutator
from puya.utils import unique

logger: structlog.typing.FilteringBoundLogger = structlog.get_logger(__name__)

Expand Down Expand Up @@ -180,7 +181,7 @@ def remove_target(parent: models.BasicBlock, to_remove: models.BasicBlock) -> No
block.terminator = models.Goto(
source_location=terminator.source_location, target=goto
)
for target in terminator.targets():
for target in unique(terminator.targets()):
if target is not goto:
remove_target(block, target)
# TODO: do these belong in constant_propagation?
Expand Down
1 change: 0 additions & 1 deletion src/puyapy-stubs/_primitives.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ class UInt64:
def __ior__(self, other: UInt64 | int) -> UInt64: ...
# ~
def __invert__(self) -> UInt64: ...
# used to turn this into an index e.g. to a list

class Bytes(t.Iterable[Bytes]):
@t.overload
Expand Down

0 comments on commit 2c7de55

Please sign in to comment.