VM fix for refs
This commit is contained in:
parent
6758fbd06e
commit
7cf87dfac6
2 changed files with 20 additions and 2 deletions
|
|
@ -210,8 +210,14 @@ proc putIntoNode(n: var PNode; x: TFullReg) =
|
||||||
of rkInt: n.intVal = x.intVal
|
of rkInt: n.intVal = x.intVal
|
||||||
of rkFloat: n.floatVal = x.floatVal
|
of rkFloat: n.floatVal = x.floatVal
|
||||||
of rkNode:
|
of rkNode:
|
||||||
if nfIsRef in x.node.flags: n = x.node
|
if nfIsRef in x.node.flags:
|
||||||
else: n[] = x.node[]
|
n = x.node
|
||||||
|
else:
|
||||||
|
let destIsRef = nfIsRef in n.flags
|
||||||
|
n[] = x.node[]
|
||||||
|
# Ref-ness must be kept for the destination
|
||||||
|
if destIsRef:
|
||||||
|
n.flags.incl nfIsRef
|
||||||
of rkRegisterAddr: putIntoNode(n, x.regAddr[])
|
of rkRegisterAddr: putIntoNode(n, x.regAddr[])
|
||||||
of rkNodeAddr: n[] = x.nodeAddr[][]
|
of rkNodeAddr: n[] = x.nodeAddr[][]
|
||||||
|
|
||||||
|
|
|
||||||
12
tests/vm/tref.nim
Normal file
12
tests/vm/tref.nim
Normal file
|
|
@ -0,0 +1,12 @@
|
||||||
|
static:
|
||||||
|
var
|
||||||
|
a: ref string
|
||||||
|
b: ref string
|
||||||
|
new a
|
||||||
|
|
||||||
|
a[] = "Hello world"
|
||||||
|
b = a
|
||||||
|
|
||||||
|
b[5] = 'c'
|
||||||
|
doAssert a[] == "Hellocworld"
|
||||||
|
doAssert b[] == "Hellocworld"
|
||||||
Loading…
Add table
Add a link
Reference in a new issue