fixes #4863
This commit is contained in:
parent
34b826a64d
commit
d0ec83eaa8
2 changed files with 27 additions and 4 deletions
|
|
@ -1021,11 +1021,9 @@ proc typeRel(c: var TCandidate, f, aOrig: PType, doBind = true): TTypeRelation =
|
||||||
var fskip = skippedNone
|
var fskip = skippedNone
|
||||||
let aobj = x.skipToObject(askip)
|
let aobj = x.skipToObject(askip)
|
||||||
let fobj = genericBody.lastSon.skipToObject(fskip)
|
let fobj = genericBody.lastSon.skipToObject(fskip)
|
||||||
|
var depth = -1
|
||||||
if fobj != nil and aobj != nil and askip == fskip:
|
if fobj != nil and aobj != nil and askip == fskip:
|
||||||
let depth = isObjectSubtype(c, aobj, fobj, f)
|
depth = isObjectSubtype(c, aobj, fobj, f)
|
||||||
if depth >= 0:
|
|
||||||
c.inheritancePenalty += depth
|
|
||||||
return if depth == 0: isGeneric else: isSubtype
|
|
||||||
result = typeRel(c, genericBody, x)
|
result = typeRel(c, genericBody, x)
|
||||||
if result != isNone:
|
if result != isNone:
|
||||||
# see tests/generics/tgeneric3.nim for an example that triggers this
|
# see tests/generics/tgeneric3.nim for an example that triggers this
|
||||||
|
|
@ -1047,6 +1045,11 @@ proc typeRel(c: var TCandidate, f, aOrig: PType, doBind = true): TTypeRelation =
|
||||||
else:
|
else:
|
||||||
put(c, f.sons[i], x)
|
put(c, f.sons[i], x)
|
||||||
|
|
||||||
|
if depth >= 0:
|
||||||
|
c.inheritancePenalty += depth
|
||||||
|
# bug #4863: We still need to bind generic alias crap, so
|
||||||
|
# we cannot return immediately:
|
||||||
|
result = if depth == 0: isGeneric else: isSubtype
|
||||||
of tyAnd:
|
of tyAnd:
|
||||||
considerPreviousT:
|
considerPreviousT:
|
||||||
result = isEqual
|
result = isEqual
|
||||||
|
|
|
||||||
20
tests/generics/tstatictalias.nim
Normal file
20
tests/generics/tstatictalias.nim
Normal file
|
|
@ -0,0 +1,20 @@
|
||||||
|
discard """
|
||||||
|
output: '''G:0,1:0.1
|
||||||
|
G:0,1:0.1
|
||||||
|
H:1:0.1'''
|
||||||
|
"""
|
||||||
|
|
||||||
|
type
|
||||||
|
G[i,j:static[int]] = object
|
||||||
|
v:float
|
||||||
|
H[j:static[int]] = G[0,j]
|
||||||
|
proc p[i,j:static[int]](x:G[i,j]) = echo "G:",i,",",j,":",x.v
|
||||||
|
proc q[j:static[int]](x:H[j]) = echo "H:",j,":",x.v
|
||||||
|
|
||||||
|
var
|
||||||
|
g0 = G[0,1](v: 0.1)
|
||||||
|
h0:H[1] = g0
|
||||||
|
p(g0)
|
||||||
|
p(h0)
|
||||||
|
q(h0)
|
||||||
|
# bug #4863
|
||||||
Loading…
Add table
Add a link
Reference in a new issue