mirror of
https://github.com/nim-lang/Nim.git
synced 2026-01-02 19:22:40 +00:00
fixes #6489
This commit is contained in:
@@ -1693,7 +1693,7 @@ proc genRangeChck(p: BProc, n: PNode, d: var TLoc, magic: string) =
|
||||
|
||||
proc genConv(p: BProc, e: PNode, d: var TLoc) =
|
||||
let destType = e.typ.skipTypes({tyVar, tyGenericInst, tyAlias})
|
||||
if compareTypes(destType, e.sons[1].typ, dcEqIgnoreDistinct):
|
||||
if sameBackendType(destType, e.sons[1].typ):
|
||||
expr(p, e.sons[1], d)
|
||||
else:
|
||||
genSomeCast(p, e, d)
|
||||
|
||||
@@ -240,6 +240,8 @@ proc instantiateProcType(c: PContext, pt: TIdTable,
|
||||
resetIdTable(cl.localCache)
|
||||
result.sons[0] = replaceTypeVarsT(cl, result.sons[0])
|
||||
result.n.sons[0] = originalParams[0].copyTree
|
||||
if result.sons[0] != nil:
|
||||
propagateToOwner(result, result.sons[0])
|
||||
|
||||
eraseVoidParams(result)
|
||||
skipIntLiteralParams(result)
|
||||
|
||||
@@ -525,7 +525,7 @@ proc notNilCheck(tracked: PEffects, n: PNode, paramType: PType) =
|
||||
# addr(x[]) can't be proven, but addr(x) can:
|
||||
if not containsNode(n, {nkDerefExpr, nkHiddenDeref}): return
|
||||
elif (n.kind == nkSym and n.sym.kind in routineKinds) or
|
||||
n.kind in procDefs+{nkObjConstr, nkBracket}:
|
||||
n.kind in procDefs+{nkObjConstr, nkBracket, nkClosure}:
|
||||
# 'p' is not nil obviously:
|
||||
return
|
||||
case impliesNotNil(tracked.guards, n)
|
||||
|
||||
@@ -522,8 +522,8 @@ proc replaceTypeVarsTAux(cl: var TReplTypeVars, t: PType): PType =
|
||||
if r2.kind in {tyPtr, tyRef}:
|
||||
r = skipTypes(r2, {tyPtr, tyRef})
|
||||
result.sons[i] = r
|
||||
#if result.kind != tyArray or i != 0:
|
||||
# propagateToOwner(result, r)
|
||||
if result.kind != tyArray or i != 0:
|
||||
propagateToOwner(result, r)
|
||||
# bug #4677: Do not instantiate effect lists
|
||||
result.n = replaceTypeVarsN(cl, result.n, ord(result.kind==tyProc))
|
||||
case result.kind
|
||||
|
||||
@@ -972,7 +972,12 @@ proc sameTypeAux(x, y: PType, c: var TSameTypeClosure): bool =
|
||||
tyArray, tyProc, tyVarargs, tyOrdinal, tyTypeClasses, tyOpt:
|
||||
cycleCheck()
|
||||
if a.kind == tyUserTypeClass and a.n != nil: return a.n == b.n
|
||||
result = sameChildrenAux(a, b, c) and sameFlags(a, b)
|
||||
result = sameChildrenAux(a, b, c)
|
||||
if result:
|
||||
if IgnoreTupleFields in c.flags:
|
||||
result = a.flags * {tfVarIsPtr} == b.flags * {tfVarIsPtr}
|
||||
else:
|
||||
result = sameFlags(a, b)
|
||||
if result and ExactGcSafety in c.flags:
|
||||
result = a.flags * {tfThread} == b.flags * {tfThread}
|
||||
if result and a.kind == tyProc:
|
||||
@@ -992,6 +997,7 @@ proc sameTypeAux(x, y: PType, c: var TSameTypeClosure): bool =
|
||||
proc sameBackendType*(x, y: PType): bool =
|
||||
var c = initSameTypeClosure()
|
||||
c.flags.incl IgnoreTupleFields
|
||||
c.cmp = dcEqIgnoreDistinct
|
||||
result = sameTypeAux(x, y, c)
|
||||
|
||||
proc compareTypes*(x, y: PType,
|
||||
|
||||
@@ -55,4 +55,10 @@ proc parse(cts: CTS, jn: JsonNode) =
|
||||
thing: jn.getStr("thing")
|
||||
)
|
||||
|
||||
cts.subs_by_sid[0] = ces
|
||||
cts.subs_by_sid[0] = ces
|
||||
|
||||
|
||||
# bug #6489
|
||||
|
||||
proc p(x: proc(){.closure.} not nil) = discard
|
||||
p(proc(){.closure.} = discard)
|
||||
|
||||
Reference in New Issue
Block a user