mirror of
https://github.com/nim-lang/Nim.git
synced 2026-06-03 18:34:43 +00:00
fixes endless recursion with static type parameters
This commit is contained in:
@@ -1016,9 +1016,17 @@ proc typeRel(c: var TCandidate, f, aOrig: PType, doBind = true): TTypeRelation =
|
||||
if result != isNone: put(c.bindings, f, aOrig)
|
||||
else:
|
||||
result = isNone
|
||||
elif prev.kind == tyStatic:
|
||||
if aOrig.kind == tyStatic:
|
||||
result = typeRel(c, prev.lastSon, a)
|
||||
if result != isNone and prev.n != nil:
|
||||
if not exprStructuralEquivalent(prev.n, aOrig.n):
|
||||
result = isNone
|
||||
else: result = isNone
|
||||
else:
|
||||
result = typeRel(c, prev, aOrig)
|
||||
|
||||
# XXX endless recursion?
|
||||
#result = typeRel(c, prev, aOrig)
|
||||
result = isNone
|
||||
of tyTypeDesc:
|
||||
var prev = PType(idTableGet(c.bindings, f))
|
||||
if prev == nil:
|
||||
|
||||
17
tests/metatype/tstaticvector.nim
Normal file
17
tests/metatype/tstaticvector.nim
Normal file
@@ -0,0 +1,17 @@
|
||||
|
||||
type
|
||||
RectArray*[R, C: static[int], T] = distinct array[R * C, T]
|
||||
|
||||
StaticMatrix*[R, C: static[int], T] = object
|
||||
elements*: RectArray[R, C, T]
|
||||
|
||||
StaticVector*[N: static[int], T] = StaticMatrix[N, 1, T]
|
||||
|
||||
proc foo*[N, T](a: StaticVector[N, T]): T = 0.T
|
||||
proc foobar*[N, T](a, b: StaticVector[N, T]): T = 0.T
|
||||
|
||||
|
||||
var a: StaticVector[3, int]
|
||||
|
||||
echo foo(a) # OK
|
||||
echo foobar(a, a) # <--- hangs compiler
|
||||
Reference in New Issue
Block a user