fix #18310 system.== in vm for NimNode (#18313)

* fix #18310 == in vm

* fixup

* fixup
This commit is contained in:
Timothee Cour 2021-06-21 00:46:31 -07:00 • committed by GitHub
commit ad70a65e0e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 5 deletions

View file

@ -10,14 +10,15 @@
## This file implements the new evaluation engine for Nim code. ## This file implements the new evaluation engine for Nim code.
## An instruction is 1-3 int32s in memory, it is a register based VM. ## An instruction is 1-3 int32s in memory, it is a register based VM.
import ast except getstr
import import
strutils, msgs, vmdef, vmgen, nimsets, types, passes, std/[strutils, tables, parseutils],
parser, vmdeps, idents, trees, renderer, options, transf, parseutils, msgs, vmdef, vmgen, nimsets, types, passes,
vmmarshal, gorgeimpl, lineinfos, tables, btrees, macrocacheimpl, parser, vmdeps, idents, trees, renderer, options, transf,
vmmarshal, gorgeimpl, lineinfos, btrees, macrocacheimpl,
modulegraphs, sighashes, int128, vmprofiler modulegraphs, sighashes, int128, vmprofiler
import ast except getstr
from semfold import leValueConv, ordinalValToString from semfold import leValueConv, ordinalValToString
from evaltempl import evalTemplate from evaltempl import evalTemplate
from magicsys import getSysType from magicsys import getSysType
@ -1026,7 +1027,7 @@ proc rawExecute(c: PCtx, start: int, tos: PStackFrame): TFullReg =
let nc = regs[rc].node let nc = regs[rc].node
if nb.kind != nc.kind: discard if nb.kind != nc.kind: discard
elif (nb == nc) or (nb.kind == nkNilLit): ret = true # intentional elif (nb == nc) or (nb.kind == nkNilLit): ret = true # intentional
elif (nb.kind in {nkSym, nkTupleConstr, nkClosure} and nb.typ.kind == tyProc) and sameConstant(nb, nc): elif nb.kind in {nkSym, nkTupleConstr, nkClosure} and nb.typ != nil and nb.typ.kind == tyProc and sameConstant(nb, nc):
ret = true ret = true
# this also takes care of procvar's, represented as nkTupleConstr, e.g. (nil, nil) # this also takes care of procvar's, represented as nkTupleConstr, e.g. (nil, nil)
elif nb.kind == nkIntLit and nc.kind == nkIntLit and nb.intVal == nc.intVal: # TODO: nkPtrLit elif nb.kind == nkIntLit and nc.kind == nkIntLit and nb.intVal == nc.intVal: # TODO: nkPtrLit

View file

@ -256,6 +256,17 @@ block:
doAssert f == @[] doAssert f == @[]
block: # bug #18310
macro t() : untyped =
let
x = nnkTupleConstr.newTree(newLit(1))
y = nnkTupleConstr.newTree(newLit(2))
doAssert not (x == y) # not using != intentionally
doAssert not(cast[int](x) == cast[int](y))
doAssert not(system.`==`(x, y))
doAssert system.`==`(x, x)
t()
block: # bug #10815 block: # bug #10815
type type
Opcode = enum Opcode = enum