mirror of
https://github.com/nim-lang/Nim.git
synced 2026-02-16 16:14:20 +00:00
Merge pull request #1972 from skyfex/vm_opcLdConst
Test and fix for VM issue
This commit is contained in:
@@ -984,6 +984,7 @@ proc rawExecute(c: PCtx, start: int, tos: PStackFrame): TFullReg =
|
||||
let rb = instr.regBx - wordExcess
|
||||
let cnst = c.constants.sons[rb]
|
||||
if fitsRegister(cnst.typ):
|
||||
myreset(regs[ra])
|
||||
putIntoReg(regs[ra], cnst)
|
||||
else:
|
||||
ensureKind(rkNode)
|
||||
|
||||
14
tests/vm/tldconst.nim
Normal file
14
tests/vm/tldconst.nim
Normal file
@@ -0,0 +1,14 @@
|
||||
# Passes if it compiles
|
||||
# From issue #1946
|
||||
|
||||
type
|
||||
Part = object
|
||||
index: int ## array index of argument to be accessed
|
||||
|
||||
proc foobar(): int =
|
||||
var x: Part
|
||||
if x.index < high(int):
|
||||
discard
|
||||
0
|
||||
|
||||
const x = foobar()
|
||||
Reference in New Issue
Block a user