Skip to content

Commit 0c4b028

Browse files
authored
Fix bug caused by type check fix (bloqade-circuit#566) (#542)
Fixes [bloqade-circuit/issues/566](QuEraComputing/bloqade-circuit#566)
1 parent a61e51f commit 0c4b028

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

src/kirin/dialects/scf/stmts.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ def __init__(
4141
then_body_block = None
4242
else: # then_body.IS_BLOCK:
4343
then_body_block = cast(Block, then_body)
44-
then_body_region = cast(Region, then_body)
44+
then_body_region = Region(then_body_block)
4545

4646
if else_body is None:
4747
else_body_region = ir.Region()

test/dialects/scf/test_ifelse.py

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from kirin import ir
44
from kirin.passes import Fold
55
from kirin.prelude import python_basic
6-
from kirin.dialects import scf, func, lowering
6+
from kirin.dialects import py, scf, func, lowering
77

88
# TODO:
99
# test_cons
@@ -150,3 +150,19 @@ def main(n: int):
150150
assert main(2) == 1.0
151151
assert main(1) == 1.0
152152
assert main(0) == 0.0
153+
154+
155+
def test_manual_construct_ifelse_from_blocks():
156+
scf.IfElse(
157+
cond=ir.TestValue(),
158+
then_body=ir.Block(
159+
stmts=[
160+
py.Constant(5),
161+
],
162+
),
163+
else_body=ir.Block(
164+
stmts=[
165+
py.Constant(11),
166+
],
167+
),
168+
)

0 commit comments

Comments
 (0)