Skip to content

Commit 679bc3d

Browse files
authored
fix: worklist pop should always pop first (#384)
This should fix the error in constprop. cc: @kaihsin
1 parent 8270794 commit 679bc3d

File tree

2 files changed

+34
-1
lines changed

2 files changed

+34
-1
lines changed

src/kirin/worklist.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,5 +26,5 @@ def extend(self, items: Iterable[ElemType]) -> None:
2626

2727
def pop(self) -> ElemType | None:
2828
if self._stack:
29-
return self._stack.pop()
29+
return self._stack.pop(0)
3030
return None
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
from kirin.prelude import basic_no_opt
2+
from kirin.analysis import const
3+
4+
5+
def test_worklist_bfs():
6+
@basic_no_opt
7+
def make_ker(val: float):
8+
9+
def ker(i: float):
10+
return i + val
11+
12+
return ker
13+
14+
@basic_no_opt
15+
def test(x: str, y: float, flag: bool):
16+
17+
if x == "x":
18+
val = 1.0
19+
else:
20+
val = 2.0
21+
22+
if flag:
23+
ker = make_ker(val=val)
24+
25+
else:
26+
ker = make_ker(val=val)
27+
28+
return ker
29+
30+
# test.print()
31+
prop = const.Propagate(basic_no_opt)
32+
frame, ret = prop.run_analysis(test)
33+
assert isinstance(ret, const.PartialLambda)

0 commit comments

Comments
 (0)