Skip to content

Commit 07108ee

Browse files
authored
add tests for hinted isequal (#205)
this is a bug found by @kaihsin
1 parent 5fdb0d8 commit 07108ee

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

src/kirin/ir/attrs/types.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -481,13 +481,6 @@ def __init__(self, type: TypeAttribute, data: HintedData):
481481
type = type.type
482482
self.type = type
483483

484-
def is_equal(self, other: TypeAttribute) -> bool:
485-
return (
486-
isinstance(other, Hinted)
487-
and self.data == other.data
488-
and self.type.is_equal(other.type)
489-
)
490-
491484
def is_subseteq_fallback(self, other: TypeAttribute) -> bool:
492485
return self.type.is_subseteq(other)
493486

test/dialects/test_pytypes.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import pytest
22

3+
from kirin.analysis import const
34
from kirin.ir.attrs.types import (
45
Int,
56
Bool,
@@ -8,6 +9,7 @@
89
Slice,
910
Tuple,
1011
Union,
12+
Hinted,
1113
String,
1214
Vararg,
1315
AnyType,
@@ -111,3 +113,9 @@ def test_generic_topbottom():
111113
assert t.meet(TypeAttribute.bottom()).is_subseteq(TypeAttribute.bottom())
112114
assert t.join(TypeAttribute.top()).is_equal(TypeAttribute.top())
113115
assert t.meet(TypeAttribute.top()).is_equal(t)
116+
117+
118+
def test_hinted():
119+
assert Hinted(Int, const.Value(1)).is_equal(Int)
120+
assert Hinted(Int, const.Value(1)).is_equal(Hinted(Int, const.Value(2)))
121+
assert Hinted(Int, const.Value(1)).is_subseteq(Hinted(Int, const.Value(2)))

0 commit comments

Comments
 (0)