parent
c949b81efd
commit
0ecb709cbe
2 changed files with 30 additions and 5 deletions
|
|
@ -362,12 +362,14 @@ proc genObjectInit(p: BProc, section: TCProcSection, t: PType, a: var TLoc,
|
||||||
linefmt(p, section, "$1.m_type = $2;$n", [r, genTypeInfo(p.module, t, a.lode.info)])
|
linefmt(p, section, "$1.m_type = $2;$n", [r, genTypeInfo(p.module, t, a.lode.info)])
|
||||||
of frEmbedded:
|
of frEmbedded:
|
||||||
if optTinyRtti in p.config.globalOptions:
|
if optTinyRtti in p.config.globalOptions:
|
||||||
|
var tmp: TLoc
|
||||||
if mode == constructRefObj:
|
if mode == constructRefObj:
|
||||||
var n = newNodeIT(nkObjConstr, a.lode.info, t)
|
let objType = t.skipTypes(abstractInst+{tyRef})
|
||||||
n.add newNodeIT(nkType, a.lode.info, t)
|
rawConstExpr(p, newNodeIT(nkType, a.lode.info, objType), tmp)
|
||||||
genObjConstr(p, n, a)
|
linefmt(p, cpsStmts,
|
||||||
|
"#nimCopyMem((void*)$1, (NIM_CONST void*)&$2, sizeof($3));$n",
|
||||||
|
[rdLoc(a), rdLoc(tmp), getTypeDesc(p.module, objType)])
|
||||||
else:
|
else:
|
||||||
var tmp: TLoc
|
|
||||||
rawConstExpr(p, newNodeIT(nkType, a.lode.info, t), tmp)
|
rawConstExpr(p, newNodeIT(nkType, a.lode.info, t), tmp)
|
||||||
genAssignment(p, a, tmp, {})
|
genAssignment(p, a, tmp, {})
|
||||||
else:
|
else:
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
discard """
|
discard """
|
||||||
output: "true"
|
output: '''true
|
||||||
|
OK'''
|
||||||
cmd: "nim c --gc:arc $file"
|
cmd: "nim c --gc:arc $file"
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
@ -31,3 +32,25 @@ assert y.more[2] of MyObject1
|
||||||
assert y.more[2] of RootObj
|
assert y.more[2] of RootObj
|
||||||
|
|
||||||
echo "true"
|
echo "true"
|
||||||
|
|
||||||
|
# bug #12978
|
||||||
|
type
|
||||||
|
Vector2* = object of RootObj
|
||||||
|
x*, y*: float
|
||||||
|
|
||||||
|
type
|
||||||
|
Vertex* = ref object
|
||||||
|
point*: Vector2
|
||||||
|
|
||||||
|
proc newVertex*(p: Vector2): Vertex =
|
||||||
|
return Vertex(point: p)
|
||||||
|
|
||||||
|
proc createVertex*(p: Vector2): Vertex =
|
||||||
|
result = newVertex(p)
|
||||||
|
|
||||||
|
proc p =
|
||||||
|
var x = Vector2(x: 1, y: 2)
|
||||||
|
let other = createVertex(x)
|
||||||
|
echo "OK"
|
||||||
|
|
||||||
|
p()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue