diff options
-rw-r--r-- | compiler/ccgexprs.nim | 3 | ||||
-rw-r--r-- | tests/assign/tobjasgn.nim | 15 |
2 files changed, 13 insertions, 5 deletions
diff --git a/compiler/ccgexprs.nim b/compiler/ccgexprs.nim index e346e1b53..7c4cc2b80 100644 --- a/compiler/ccgexprs.nim +++ b/compiler/ccgexprs.nim @@ -1060,6 +1060,8 @@ proc genObjConstr(p: BProc, e: PNode, d: var TLoc) = t = t.sons[0].skipTypes(abstractInst) r = ropef("(*$1)", r) gcUsage(e) + else: + constructLoc(p, tmp) discard getTypeDesc(p.module, t) for i in 1 .. <e.len: let it = e.sons[i] @@ -1082,6 +1084,7 @@ proc genObjConstr(p: BProc, e: PNode, d: var TLoc) = tmp2.s = if isRef: OnHeap else: OnStack tmp2.heapRoot = tmp.r expr(p, it.sons[1], tmp2) + if d.k == locNone: d = tmp else: diff --git a/tests/assign/tobjasgn.nim b/tests/assign/tobjasgn.nim index 5f411063f..da12319cd 100644 --- a/tests/assign/tobjasgn.nim +++ b/tests/assign/tobjasgn.nim @@ -1,16 +1,21 @@ discard """ - output: '''0 + output: '''0 0 pre test a:test b:1 c:2 haha:3 assignment test a:test b:1 c:2 haha:3 ''' """ -type TSomeObj = object of TObject - Variable: int +# bug #1005 + +type + TSomeObj = object of TObject + a: int + PSomeObj = ref object + a: int var a = TSomeObj() - -echo a.Variable.`$` +var b = PSomeObj() +echo a.a, " ", b.a # bug #575 |