Skip to content

Commit d07a860

Browse files
committed
Fix length check in typeinfer. (#2)
* fixing type infer * removing the subtype * refactor * Adding comment
1 parent 4b6bce2 commit d07a860

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/bloqade/geometry/dialects/grid/_typeinfer.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,12 @@
1414
class TypeInferMethods(MethodTable):
1515

1616
def get_len(self, typ: types.TypeAttribute):
17-
if typ.is_subseteq(ilist.IListType[types.Int, types.Any]):
18-
typ = cast(types.Generic, typ)
19-
if isinstance(typ.vars[1], types.Literal):
20-
return types.Literal(typ.vars[1].data + 1)
17+
if (typ := cast(types.Generic, typ)).is_subseteq(
18+
ilist.IListType
19+
) and isinstance(typ.vars[1], types.Literal):
20+
# assume typ is Generic since it must be if it passes the first check
21+
# and the second check is to ensure that the length is a literal
22+
return types.Literal(typ.vars[1].data + 1)
2123

2224
return types.Any
2325

0 commit comments

Comments
 (0)