Merge pull request #1972 from skyfex/vm_opcLdConst
Test and fix for VM issue
This commit is contained in:
commit
4b30c6d9ce
2 changed files with 15 additions and 0 deletions
|
|
@ -984,6 +984,7 @@ proc rawExecute(c: PCtx, start: int, tos: PStackFrame): TFullReg =
|
||||||
let rb = instr.regBx - wordExcess
|
let rb = instr.regBx - wordExcess
|
||||||
let cnst = c.constants.sons[rb]
|
let cnst = c.constants.sons[rb]
|
||||||
if fitsRegister(cnst.typ):
|
if fitsRegister(cnst.typ):
|
||||||
|
myreset(regs[ra])
|
||||||
putIntoReg(regs[ra], cnst)
|
putIntoReg(regs[ra], cnst)
|
||||||
else:
|
else:
|
||||||
ensureKind(rkNode)
|
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()
|
||||||
Loading…
Add table
Add a link
Reference in a new issue