mirror of
https://github.com/nim-lang/Nim.git
synced 2026-04-06 07:38:24 +00:00
This commit is contained in:
@@ -1212,8 +1212,10 @@ proc produceSym(g: ModuleGraph; c: PContext; typ: PType; kind: TTypeAttachedOp;
|
||||
result.ast[bodyPos].add newAsgnStmt(d, src)
|
||||
else:
|
||||
var tk: TTypeKind
|
||||
var skipped: PType = nil
|
||||
if g.config.selectedGC in {gcArc, gcOrc, gcHooks, gcAtomicArc}:
|
||||
tk = skipTypes(typ, {tyOrdinal, tyRange, tyInferred, tyGenericInst, tyStatic, tyAlias, tySink}).kind
|
||||
skipped = skipTypes(typ, {tyOrdinal, tyRange, tyInferred, tyGenericInst, tyStatic, tyAlias, tySink})
|
||||
tk = skipped.kind
|
||||
else:
|
||||
tk = tyNone # no special casing for strings and seqs
|
||||
case tk
|
||||
@@ -1223,7 +1225,7 @@ proc produceSym(g: ModuleGraph; c: PContext; typ: PType; kind: TTypeAttachedOp;
|
||||
fillStrOp(a, typ, result.ast[bodyPos], d, src)
|
||||
else:
|
||||
fillBody(a, typ, result.ast[bodyPos], d, src)
|
||||
if tk == tyObject and a.kind in {attachedAsgn, attachedSink, attachedDeepCopy, attachedDup} and not isObjLackingTypeField(typ):
|
||||
if tk == tyObject and a.kind in {attachedAsgn, attachedSink, attachedDeepCopy, attachedDup} and not isObjLackingTypeField(skipped):
|
||||
# bug #19205: Do not forget to also copy the hidden type field:
|
||||
genTypeFieldCopy(a, typ, result.ast[bodyPos], d, src)
|
||||
|
||||
|
||||
7
tests/destructor/t25341.nim
Normal file
7
tests/destructor/t25341.nim
Normal file
@@ -0,0 +1,7 @@
|
||||
discard """
|
||||
cmd: "nim c --mm:orc $file"
|
||||
output: ""
|
||||
"""
|
||||
import ./t25341_aux/a, ./t25341_aux/b
|
||||
a()
|
||||
b()
|
||||
4
tests/destructor/t25341_aux/a.nim
Normal file
4
tests/destructor/t25341_aux/a.nim
Normal file
@@ -0,0 +1,4 @@
|
||||
import ./module
|
||||
|
||||
proc a*() =
|
||||
discard make1[4]().make2()
|
||||
6
tests/destructor/t25341_aux/b.nim
Normal file
6
tests/destructor/t25341_aux/b.nim
Normal file
@@ -0,0 +1,6 @@
|
||||
import ./module
|
||||
|
||||
var globalObj: Distinct2[4]
|
||||
|
||||
proc b*() =
|
||||
globalObj = make1[4]().make2()
|
||||
14
tests/destructor/t25341_aux/module.nim
Normal file
14
tests/destructor/t25341_aux/module.nim
Normal file
@@ -0,0 +1,14 @@
|
||||
type
|
||||
BaseObject*[N: static int] = object
|
||||
value*: int
|
||||
|
||||
Distinct1*[N: static int] = distinct BaseObject[N]
|
||||
Distinct2*[N: static int] = distinct BaseObject[N]
|
||||
|
||||
proc `=copy`*[N: static int](dest: var Distinct2[N], src: Distinct2[N]) {.error: "no".}
|
||||
|
||||
proc make1*[N: static int](): Distinct1[N] =
|
||||
Distinct1[N](BaseObject[N](value: 0))
|
||||
|
||||
proc make2*[N: static int](u: sink Distinct1[N]): Distinct2[N] =
|
||||
Distinct2[N](BaseObject[N](u))
|
||||
Reference in New Issue
Block a user