bugfix: don't treat generic types with different static params as the same type
This commit is contained in:
parent
b83b1383fb
commit
13e07f5d66
2 changed files with 20 additions and 0 deletions
|
|
@ -979,6 +979,9 @@ proc typeRel(c: var TCandidate, f, aOrig: PType, doBind = true): TTypeRelation =
|
||||||
of tyStatic:
|
of tyStatic:
|
||||||
if aOrig.kind == tyStatic:
|
if aOrig.kind == tyStatic:
|
||||||
result = typeRel(c, f.lastSon, a)
|
result = typeRel(c, f.lastSon, a)
|
||||||
|
if result != isNone and f.n != nil:
|
||||||
|
if not exprStructuralEquivalent(f.n, a.n):
|
||||||
|
result = isNone
|
||||||
if result != isNone: put(c.bindings, f, aOrig)
|
if result != isNone: put(c.bindings, f, aOrig)
|
||||||
else:
|
else:
|
||||||
result = isNone
|
result = isNone
|
||||||
|
|
|
||||||
|
|
@ -34,3 +34,20 @@ type
|
||||||
yes s.items is Iter[TNumber]
|
yes s.items is Iter[TNumber]
|
||||||
no s.items is Iter[float]
|
no s.items is Iter[float]
|
||||||
|
|
||||||
|
type
|
||||||
|
Foo[N: static[int], T] = object
|
||||||
|
field: array[1..N, T]
|
||||||
|
|
||||||
|
Bar[T] = Foo[4, T]
|
||||||
|
Baz[N: static[int]] = Foo[N, float]
|
||||||
|
|
||||||
|
no Foo[2, float] is Foo[3, float]
|
||||||
|
no Foo[2, float] is Foo[2, int]
|
||||||
|
|
||||||
|
yes Foo[4, string] is Foo[4, string]
|
||||||
|
yes Bar[int] is Foo[4, int]
|
||||||
|
yes Foo[4, int] is Bar[int]
|
||||||
|
|
||||||
|
no Foo[4, int] is Baz[4]
|
||||||
|
yes Foo[4, float] is Baz[4]
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue