diff options
Diffstat (limited to 'compiler/sigmatch.nim')
-rw-r--r-- | compiler/sigmatch.nim | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/compiler/sigmatch.nim b/compiler/sigmatch.nim index 61f1a7444..642f50330 100644 --- a/compiler/sigmatch.nim +++ b/compiler/sigmatch.nim @@ -511,6 +511,9 @@ proc typeRangeRel(f, a: PType): TTypeRelation {.noinline.} = proc matchUserTypeClass*(c: PContext, m: var TCandidate, ff, a: PType): TTypeRelation = var body = ff.skipTypes({tyUserTypeClassInst}) + if c.inTypeClass > 20: + localError(body.n[3].info, $body.n[3] & " too nested for type matching") + return isNone openScope(c) inc c.inTypeClass @@ -590,7 +593,7 @@ proc tryResolvingStaticExpr(c: var TCandidate, n: PNode): PNode = # Here, N-1 will be initially nkStaticExpr that can be evaluated only after # N is bound to a concrete value during the matching of the first param. # This proc is used to evaluate such static expressions. - let instantiated = replaceTypesInBody(c.c, c.bindings, n) + let instantiated = replaceTypesInBody(c.c, c.bindings, n, nil) result = c.c.semExpr(c.c, instantiated) proc typeRel(c: var TCandidate, f, aOrig: PType, doBind = true): TTypeRelation = @@ -1691,6 +1694,10 @@ proc partialMatch*(c: PContext, n, nOrig: PNode, m: var TCandidate) = matchesAux(c, n, nOrig, m, marker) proc matches*(c: PContext, n, nOrig: PNode, m: var TCandidate) = + if m.calleeSym != nil and m.calleeSym.magic in {mArrGet, mArrPut}: + m.state = csMatch + m.call = n + return var marker = initIntSet() matchesAux(c, n, nOrig, m, marker) if m.state == csNoMatch: return |