Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[backport] fix #15595 procvar == works in VM #15724

Merged
merged 2 commits into from
Oct 26, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions compiler/vm.nim
Original file line number Diff line number Diff line change
Expand Up @@ -994,8 +994,10 @@ proc rawExecute(c: PCtx, start: int, tos: PStackFrame): TFullReg =
let nb = regs[rb].node
let nc = regs[rc].node
if nb.kind != nc.kind: discard
elif (nb == nc) or (nb.kind == nkNilLit): ret = true
elif nb.kind == nkIntLit and nb.intVal == nc.intVal: # TODO: nkPtrLit
elif (nb == nc) or (nb.kind == nkNilLit): ret = true # intentional
elif sameConstant(nb, nc): ret = true
# this also takes care of procvar's, represented as nkTupleConstr, eg (nil, nil)
elif nb.kind == nkIntLit and nc.kind == nkIntLit and nb.intVal == nc.intVal: # TODO: nkPtrLit
let tb = nb.getTyp
let tc = nc.getTyp
ret = tb.kind in PtrLikeKinds and tc.kind == tb.kind
Expand Down
24 changes: 24 additions & 0 deletions tests/vm/tvmmisc.nim
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,30 @@ block: # bug #13081
static:
doAssert j1.x1 == 12

block: # bug #15595
proc fn0()=echo 0
proc fn1()=discard
proc main=
var local = 0
proc fn2()=echo local
var a0 = fn0
var a1 = fn1
var a2 = fn2
var a3: proc()
var a4: proc()
doAssert a0 == fn0 # bugfix
doAssert a1 == fn1 # ditto
doAssert a2 == fn2 # ditto

doAssert fn0 != fn1

doAssert a2 != nil
doAssert a3 == nil # bugfix

doAssert a3 == a4 # bugfix
static: main()
main()

# bug #15363
import sequtils

Expand Down