diff options
author | Andreas Rumpf <rumpf_a@web.de> | 2016-06-02 17:23:39 +0200 |
---|---|---|
committer | Andreas Rumpf <rumpf_a@web.de> | 2016-06-02 17:23:39 +0200 |
commit | 87ffff96d2a59a657631022b8dc227196727d311 (patch) | |
tree | 51c8f5adc8ce5aea2437f1fbdc18e694c8e97e90 | |
parent | c8c50011512fbe1c9149b6e0d7c8f9a741726cca (diff) | |
download | Nim-87ffff96d2a59a657631022b8dc227196727d311.tar.gz |
fixes #4186
-rw-r--r-- | compiler/ccgexprs.nim | 2 | ||||
-rw-r--r-- | tests/ccgbugs/tclosureeq.nim | 19 |
2 files changed, 20 insertions, 1 deletions
diff --git a/compiler/ccgexprs.nim b/compiler/ccgexprs.nim index 917f72b16..8fe9cdb72 100644 --- a/compiler/ccgexprs.nim +++ b/compiler/ccgexprs.nim @@ -611,7 +611,7 @@ proc genEqProc(p: BProc, e: PNode, d: var TLoc) = assert(e.sons[2].typ != nil) initLocExpr(p, e.sons[1], a) initLocExpr(p, e.sons[2], b) - if a.t.callConv == ccClosure: + if a.t.skipTypes(abstractInst).callConv == ccClosure: putIntoDest(p, d, e.typ, "($1.ClPrc == $2.ClPrc && $1.ClEnv == $2.ClEnv)" % [rdLoc(a), rdLoc(b)]) else: diff --git a/tests/ccgbugs/tclosureeq.nim b/tests/ccgbugs/tclosureeq.nim new file mode 100644 index 000000000..0486a9559 --- /dev/null +++ b/tests/ccgbugs/tclosureeq.nim @@ -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 |