mirror of
https://github.com/nim-lang/Nim.git
synced 2025-12-28 17:04:41 +00:00
fixes #23505
This commit is contained in:
@@ -412,7 +412,10 @@ proc genDefaultCall(t: PType; c: Con; info: TLineInfo): PNode =
|
||||
proc destructiveMoveVar(n: PNode; c: var Con; s: var Scope): PNode =
|
||||
# generate: (let tmp = v; reset(v); tmp)
|
||||
if (not hasDestructor(c, n.typ)) and c.inEnsureMove == 0:
|
||||
assert n.kind != nkSym or not hasDestructor(c, n.sym.typ)
|
||||
assert n.kind != nkSym or not hasDestructor(c, n.sym.typ) or
|
||||
(n.typ.kind == tyPtr and n.sym.typ.kind == tyRef)
|
||||
# bug #23505; transformed by `transf`: addr (deref ref) -> ptr
|
||||
# we know it's really a pointer; so here we assign it directly
|
||||
result = copyTree(n)
|
||||
else:
|
||||
result = newNodeIT(nkStmtListExpr, n.info, n.typ)
|
||||
|
||||
@@ -714,3 +714,16 @@ block:
|
||||
|
||||
let c: uint = 300'u
|
||||
doAssert $arrayWith(c, 3) == "[300, 300, 300]"
|
||||
|
||||
block: # bug #23505
|
||||
type
|
||||
K = object
|
||||
C = object
|
||||
value: ptr K
|
||||
|
||||
proc init(T: type C): C =
|
||||
let tmp = new K
|
||||
C(value: addr tmp[])
|
||||
|
||||
discard init(C)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user