mirror of
https://github.com/nim-lang/Nim.git
synced 2026-06-06 20:04:18 +00:00
fixes #4653
This commit is contained in:
@@ -670,6 +670,8 @@ proc genDeref(p: BProc, e: PNode, d: var TLoc; enforceDeref=false) =
|
||||
#if e[0].kind != nkBracketExpr:
|
||||
# message(e.info, warnUser, "CAME HERE " & renderTree(e))
|
||||
expr(p, e.sons[0], d)
|
||||
if e.sons[0].typ.skipTypes(abstractInst).kind == tyRef:
|
||||
d.s = OnHeap
|
||||
else:
|
||||
var a: TLoc
|
||||
let typ = skipTypes(e.sons[0].typ, abstractInst)
|
||||
|
||||
26
tests/ccgbugs/twrong_rc_for_refarray.nim
Normal file
26
tests/ccgbugs/twrong_rc_for_refarray.nim
Normal file
@@ -0,0 +1,26 @@
|
||||
discard """
|
||||
output: '''m[0][0] = 1.0
|
||||
m[0][0] = 2.0'''
|
||||
"""
|
||||
# bug #4653
|
||||
type
|
||||
Vector = ref array[2, float64]
|
||||
Matrix = ref array[2, Vector]
|
||||
|
||||
proc newVector(): Vector =
|
||||
new(result)
|
||||
|
||||
proc newMatrix(): Matrix =
|
||||
new(result)
|
||||
for ix in 0 .. 1:
|
||||
result[ix] = newVector()
|
||||
|
||||
let m = newMatrix()
|
||||
|
||||
m[0][0] = 1.0
|
||||
echo "m[0][0] = ", m[0][0]
|
||||
|
||||
GC_fullCollect()
|
||||
|
||||
m[0][0] = 2.0
|
||||
echo "m[0][0] = ", m[0][0]
|
||||
Reference in New Issue
Block a user