Skip to content
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 src/kirin/dialects/scf/stmts.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def __init__(
then_body_block = None
else: # then_body.IS_BLOCK:
then_body_block = cast(Block, then_body)
then_body_region = cast(Region, then_body)
then_body_region = Region(then_body_block)

if else_body is None:
else_body_region = ir.Region()
Expand Down
18 changes: 17 additions & 1 deletion test/dialects/scf/test_ifelse.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from kirin import ir
from kirin.passes import Fold
from kirin.prelude import python_basic
from kirin.dialects import scf, func, lowering
from kirin.dialects import py, scf, func, lowering

# TODO:
# test_cons
Expand Down Expand Up @@ -150,3 +150,19 @@ def main(n: int):
assert main(2) == 1.0
assert main(1) == 1.0
assert main(0) == 0.0


def test_manual_construct_ifelse_from_blocks():
scf.IfElse(
cond=ir.TestValue(),
then_body=ir.Block(
stmts=[
py.Constant(5),
],
),
else_body=ir.Block(
stmts=[
py.Constant(11),
],
),
)