fixes #6489
This commit is contained in:
parent
95a5373d07
commit
8a601669ef
6 changed files with 20 additions and 6 deletions
|
|
@ -1693,7 +1693,7 @@ proc genRangeChck(p: BProc, n: PNode, d: var TLoc, magic: string) =
|
||||||
|
|
||||||
proc genConv(p: BProc, e: PNode, d: var TLoc) =
|
proc genConv(p: BProc, e: PNode, d: var TLoc) =
|
||||||
let destType = e.typ.skipTypes({tyVar, tyGenericInst, tyAlias})
|
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)
|
expr(p, e.sons[1], d)
|
||||||
else:
|
else:
|
||||||
genSomeCast(p, e, d)
|
genSomeCast(p, e, d)
|
||||||
|
|
|
||||||
|
|
@ -240,6 +240,8 @@ proc instantiateProcType(c: PContext, pt: TIdTable,
|
||||||
resetIdTable(cl.localCache)
|
resetIdTable(cl.localCache)
|
||||||
result.sons[0] = replaceTypeVarsT(cl, result.sons[0])
|
result.sons[0] = replaceTypeVarsT(cl, result.sons[0])
|
||||||
result.n.sons[0] = originalParams[0].copyTree
|
result.n.sons[0] = originalParams[0].copyTree
|
||||||
|
if result.sons[0] != nil:
|
||||||
|
propagateToOwner(result, result.sons[0])
|
||||||
|
|
||||||
eraseVoidParams(result)
|
eraseVoidParams(result)
|
||||||
skipIntLiteralParams(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:
|
# addr(x[]) can't be proven, but addr(x) can:
|
||||||
if not containsNode(n, {nkDerefExpr, nkHiddenDeref}): return
|
if not containsNode(n, {nkDerefExpr, nkHiddenDeref}): return
|
||||||
elif (n.kind == nkSym and n.sym.kind in routineKinds) or
|
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:
|
# 'p' is not nil obviously:
|
||||||
return
|
return
|
||||||
case impliesNotNil(tracked.guards, n)
|
case impliesNotNil(tracked.guards, n)
|
||||||
|
|
|
||||||
|
|
@ -522,8 +522,8 @@ proc replaceTypeVarsTAux(cl: var TReplTypeVars, t: PType): PType =
|
||||||
if r2.kind in {tyPtr, tyRef}:
|
if r2.kind in {tyPtr, tyRef}:
|
||||||
r = skipTypes(r2, {tyPtr, tyRef})
|
r = skipTypes(r2, {tyPtr, tyRef})
|
||||||
result.sons[i] = r
|
result.sons[i] = r
|
||||||
#if result.kind != tyArray or i != 0:
|
if result.kind != tyArray or i != 0:
|
||||||
# propagateToOwner(result, r)
|
propagateToOwner(result, r)
|
||||||
# bug #4677: Do not instantiate effect lists
|
# bug #4677: Do not instantiate effect lists
|
||||||
result.n = replaceTypeVarsN(cl, result.n, ord(result.kind==tyProc))
|
result.n = replaceTypeVarsN(cl, result.n, ord(result.kind==tyProc))
|
||||||
case result.kind
|
case result.kind
|
||||||
|
|
|
||||||
|
|
@ -972,7 +972,12 @@ proc sameTypeAux(x, y: PType, c: var TSameTypeClosure): bool =
|
||||||
tyArray, tyProc, tyVarargs, tyOrdinal, tyTypeClasses, tyOpt:
|
tyArray, tyProc, tyVarargs, tyOrdinal, tyTypeClasses, tyOpt:
|
||||||
cycleCheck()
|
cycleCheck()
|
||||||
if a.kind == tyUserTypeClass and a.n != nil: return a.n == b.n
|
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:
|
if result and ExactGcSafety in c.flags:
|
||||||
result = a.flags * {tfThread} == b.flags * {tfThread}
|
result = a.flags * {tfThread} == b.flags * {tfThread}
|
||||||
if result and a.kind == tyProc:
|
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 =
|
proc sameBackendType*(x, y: PType): bool =
|
||||||
var c = initSameTypeClosure()
|
var c = initSameTypeClosure()
|
||||||
c.flags.incl IgnoreTupleFields
|
c.flags.incl IgnoreTupleFields
|
||||||
|
c.cmp = dcEqIgnoreDistinct
|
||||||
result = sameTypeAux(x, y, c)
|
result = sameTypeAux(x, y, c)
|
||||||
|
|
||||||
proc compareTypes*(x, y: PType,
|
proc compareTypes*(x, y: PType,
|
||||||
|
|
|
||||||
|
|
@ -55,4 +55,10 @@ proc parse(cts: CTS, jn: JsonNode) =
|
||||||
thing: jn.getStr("thing")
|
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)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue