Skip to content

Commit 84de3fb

Browse files
cduckRoger-luo
authored andcommitted
Fix bug caused by type check fix (bloqade-circuit#566) (#542)
Fixes [bloqade-circuit/issues/566](QuEraComputing/bloqade-circuit#566)
1 parent d31bce3 commit 84de3fb

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
@@ -1,7 +1,7 @@
11
from kirin import ir
22
from kirin.passes import Fold
33
from kirin.prelude import python_basic
4-
from kirin.dialects import scf, func, lowering
4+
from kirin.dialects import py, scf, func, lowering
55

66
# TODO:
77
# test_cons
@@ -145,3 +145,19 @@ def main(n: int):
145145
assert main(2) == 1.0
146146
assert main(1) == 1.0
147147
assert main(0) == 0.0
148+
149+
150+
def test_manual_construct_ifelse_from_blocks():
151+
scf.IfElse(
152+
cond=ir.TestValue(),
153+
then_body=ir.Block(
154+
stmts=[
155+
py.Constant(5),
156+
],
157+
),
158+
else_body=ir.Block(
159+
stmts=[
160+
py.Constant(11),
161+
],
162+
),
163+
)

0 commit comments

Comments
 (0)