Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: resolves some bugs with match statements #25

Merged
merged 1 commit into from
Dec 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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