Merge pull request #1972 from skyfex/vm_opcLdConst

Test and fix for VM issue
This commit is contained in:
Andreas Rumpf
2015-01-18 03:09:36 +01:00
2 changed files with 15 additions and 0 deletions

View File

@@ -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
View 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()