Skip to content

Commit da0f256

Browse files
authored
typeinfer should return NoneType for None (#275)
I think we should just special case `None` for now before actually supporting enums and singletons (#266)
1 parent 4bad095 commit da0f256

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/kirin/dialects/func/typeinfer.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,10 @@ def const_none(self, interp: TypeInference, frame: Frame, stmt: ConstantNone):
2525

2626
@impl(Return)
2727
def return_(self, interp: TypeInference, frame: Frame, stmt: Return) -> ReturnValue:
28-
if isinstance(hint := stmt.value.hints.get("const"), const.Value):
28+
if (
29+
isinstance(hint := stmt.value.hints.get("const"), const.Value)
30+
and hint.data is not None
31+
):
2932
return ReturnValue(types.Literal(hint.data))
3033
return ReturnValue(frame.get(stmt.value))
3134

0 commit comments

Comments
 (0)