Skip to content

Commit

Permalink
fix nim-lang#18310 system.== in vm for NimNode (nim-lang#18313)
Browse files Browse the repository at this point in the history
* fix nim-lang#18310 == in vm

* fixup

* fixup
  • Loading branch information
timotheecour authored Jun 21, 2021
1 parent abd21ef commit ad70a65
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
11 changes: 6 additions & 5 deletions compiler/vm.nim
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,15 @@
## This file implements the new evaluation engine for Nim code.
## An instruction is 1-3 int32s in memory, it is a register based VM.

import ast except getstr

import
strutils, msgs, vmdef, vmgen, nimsets, types, passes,
parser, vmdeps, idents, trees, renderer, options, transf, parseutils,
vmmarshal, gorgeimpl, lineinfos, tables, btrees, macrocacheimpl,
std/[strutils, tables, parseutils],
msgs, vmdef, vmgen, nimsets, types, passes,
parser, vmdeps, idents, trees, renderer, options, transf,
vmmarshal, gorgeimpl, lineinfos, btrees, macrocacheimpl,
modulegraphs, sighashes, int128, vmprofiler

import ast except getstr
from semfold import leValueConv, ordinalValToString
from evaltempl import evalTemplate
from magicsys import getSysType
Expand Down Expand Up @@ -1026,7 +1027,7 @@ proc rawExecute(c: PCtx, start: int, tos: PStackFrame): TFullReg =
let nc = regs[rc].node
if nb.kind != nc.kind: discard
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
# 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
Expand Down
11 changes: 11 additions & 0 deletions tests/vm/tvmmisc.nim
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,17 @@ block:
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
type
Opcode = enum
Expand Down

0 comments on commit ad70a65

Please sign in to comment.