fix #1859
This commit is contained in:
parent
4316fdddf3
commit
13a18663d2
2 changed files with 34 additions and 8 deletions
|
|
@ -1004,14 +1004,18 @@ proc typeRel(c: var TCandidate, f, aOrig: PType, doBind = true): TTypeRelation =
|
||||||
result = typeRel(c, x, a) # check if it fits
|
result = typeRel(c, x, a) # check if it fits
|
||||||
|
|
||||||
of tyStatic:
|
of tyStatic:
|
||||||
if aOrig.kind == tyStatic:
|
let prev = PType(idTableGet(c.bindings, f))
|
||||||
result = typeRel(c, f.lastSon, a)
|
if prev == nil:
|
||||||
if result != isNone and f.n != nil:
|
if aOrig.kind == tyStatic:
|
||||||
if not exprStructuralEquivalent(f.n, aOrig.n):
|
result = typeRel(c, f.lastSon, a)
|
||||||
result = isNone
|
if result != isNone and f.n != nil:
|
||||||
if result != isNone: put(c.bindings, f, aOrig)
|
if not exprStructuralEquivalent(f.n, aOrig.n):
|
||||||
|
result = isNone
|
||||||
|
if result != isNone: put(c.bindings, f, aOrig)
|
||||||
|
else:
|
||||||
|
result = isNone
|
||||||
else:
|
else:
|
||||||
result = isNone
|
result = typeRel(c, prev, aOrig)
|
||||||
|
|
||||||
of tyTypeDesc:
|
of tyTypeDesc:
|
||||||
var prev = PType(idTableGet(c.bindings, f))
|
var prev = PType(idTableGet(c.bindings, f))
|
||||||
|
|
@ -1051,6 +1055,7 @@ proc typeRel(c: var TCandidate, f, aOrig: PType, doBind = true): TTypeRelation =
|
||||||
|
|
||||||
of tyFromExpr:
|
of tyFromExpr:
|
||||||
# fix the expression, so it contains the already instantiated types
|
# fix the expression, so it contains the already instantiated types
|
||||||
|
if f.n == nil: return isGeneric
|
||||||
let reevaluated = tryResolvingStaticExpr(c, f.n)
|
let reevaluated = tryResolvingStaticExpr(c, f.n)
|
||||||
case reevaluated.typ.kind
|
case reevaluated.typ.kind
|
||||||
of tyTypeDesc:
|
of tyTypeDesc:
|
||||||
|
|
|
||||||
|
|
@ -119,3 +119,24 @@ foo_2.intOrFloat
|
||||||
foo_2.yinOrYang
|
foo_2.yinOrYang
|
||||||
foo_3.yinOrYang
|
foo_3.yinOrYang
|
||||||
|
|
||||||
|
# bug 1859
|
||||||
|
|
||||||
|
type
|
||||||
|
TypeWith2Params[N, M: static[int]] = object
|
||||||
|
|
||||||
|
proc bindBothParams[N](x: TypeWith2Params[N, N]) = discard
|
||||||
|
proc dontBind1[N,M](x: TypeWith2Params[N, M]) = discard
|
||||||
|
proc dontBind2(x: TypeWith2Params) = discard
|
||||||
|
|
||||||
|
var bb_1: TypeWith2Params[2, 2]
|
||||||
|
var bb_2: TypeWith2Params[2, 3]
|
||||||
|
|
||||||
|
bindBothParams(bb_1)
|
||||||
|
reject bindBothParams(bb_2)
|
||||||
|
|
||||||
|
dontBind1 bb_1
|
||||||
|
dontBind1 bb_2
|
||||||
|
|
||||||
|
dontBind2 bb_1
|
||||||
|
dontBind2 bb_2
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue