mirror of
https://github.com/nim-lang/Nim.git
synced 2026-04-20 14:25:23 +00:00
fix #1859
This commit is contained in:
@@ -1004,15 +1004,19 @@ proc typeRel(c: var TCandidate, f, aOrig: PType, doBind = true): TTypeRelation =
|
||||
result = typeRel(c, x, a) # check if it fits
|
||||
|
||||
of tyStatic:
|
||||
if aOrig.kind == tyStatic:
|
||||
result = typeRel(c, f.lastSon, a)
|
||||
if result != isNone and f.n != nil:
|
||||
if not exprStructuralEquivalent(f.n, aOrig.n):
|
||||
result = isNone
|
||||
if result != isNone: put(c.bindings, f, aOrig)
|
||||
let prev = PType(idTableGet(c.bindings, f))
|
||||
if prev == nil:
|
||||
if aOrig.kind == tyStatic:
|
||||
result = typeRel(c, f.lastSon, a)
|
||||
if result != isNone and f.n != nil:
|
||||
if not exprStructuralEquivalent(f.n, aOrig.n):
|
||||
result = isNone
|
||||
if result != isNone: put(c.bindings, f, aOrig)
|
||||
else:
|
||||
result = isNone
|
||||
else:
|
||||
result = isNone
|
||||
|
||||
result = typeRel(c, prev, aOrig)
|
||||
|
||||
of tyTypeDesc:
|
||||
var prev = PType(idTableGet(c.bindings, f))
|
||||
if prev == nil:
|
||||
@@ -1051,6 +1055,7 @@ proc typeRel(c: var TCandidate, f, aOrig: PType, doBind = true): TTypeRelation =
|
||||
|
||||
of tyFromExpr:
|
||||
# fix the expression, so it contains the already instantiated types
|
||||
if f.n == nil: return isGeneric
|
||||
let reevaluated = tryResolvingStaticExpr(c, f.n)
|
||||
case reevaluated.typ.kind
|
||||
of tyTypeDesc:
|
||||
|
||||
@@ -119,3 +119,24 @@ foo_2.intOrFloat
|
||||
foo_2.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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user