fixes #4186
This commit is contained in:
parent
c8c5001151
commit
87ffff96d2
2 changed files with 20 additions and 1 deletions
|
|
@ -611,7 +611,7 @@ proc genEqProc(p: BProc, e: PNode, d: var TLoc) =
|
||||||
assert(e.sons[2].typ != nil)
|
assert(e.sons[2].typ != nil)
|
||||||
initLocExpr(p, e.sons[1], a)
|
initLocExpr(p, e.sons[1], a)
|
||||||
initLocExpr(p, e.sons[2], b)
|
initLocExpr(p, e.sons[2], b)
|
||||||
if a.t.callConv == ccClosure:
|
if a.t.skipTypes(abstractInst).callConv == ccClosure:
|
||||||
putIntoDest(p, d, e.typ,
|
putIntoDest(p, d, e.typ,
|
||||||
"($1.ClPrc == $2.ClPrc && $1.ClEnv == $2.ClEnv)" % [rdLoc(a), rdLoc(b)])
|
"($1.ClPrc == $2.ClPrc && $1.ClEnv == $2.ClEnv)" % [rdLoc(a), rdLoc(b)])
|
||||||
else:
|
else:
|
||||||
|
|
|
||||||
19
tests/ccgbugs/tclosureeq.nim
Normal file
19
tests/ccgbugs/tclosureeq.nim
Normal file
|
|
@ -0,0 +1,19 @@
|
||||||
|
discard """
|
||||||
|
output: '''true
|
||||||
|
true'''
|
||||||
|
"""
|
||||||
|
|
||||||
|
# bug #4186
|
||||||
|
type
|
||||||
|
Predicate[T] = proc(item: T): bool
|
||||||
|
|
||||||
|
proc a[T](): Predicate[T] =
|
||||||
|
return nil
|
||||||
|
|
||||||
|
proc b[T](): Predicate[T] =
|
||||||
|
return a[T]()
|
||||||
|
|
||||||
|
echo b[int]() == nil # ok
|
||||||
|
|
||||||
|
let x = b[int]()
|
||||||
|
echo x == nil #won't compile
|
||||||
Loading…
Add table
Add a link
Reference in a new issue