fixes #25236; broken assignment hooks of union inside variant object in orc (#25238)

fixes #25236
This commit is contained in:
ringabout
2025-10-21 22:59:22 +08:00
committed by GitHub
parent 1eae14a3be
commit c449c72498
2 changed files with 27 additions and 0 deletions

View File

@@ -1044,6 +1044,8 @@ proc fillBody(c: var TLiftCtx; t: PType; body, x, y: PNode) =
body.add genBuiltin(c, mWasMoved, "wasMoved", x)
else:
fillBodyObjT(c, t, body, x, y)
elif tfUnion in t.flags: # bug #25236
defaultOp(c, t, body, x, y)
else:
if c.kind == attachedDup:
var op2 = getAttachedOp(c.g, t, attachedAsgn)

View File

@@ -912,3 +912,28 @@ block: # bug #24754
NoCopy(id: s)
doAssert foo().id == 12
type
Sinn* {.union.} = object
c*: C
b*: bool
Regen* = object
case x*: bool
of false:
a*: Sinn
of true:
cvar*: RootRef
C* = enum
wrong1, wrong2, right
proc mainRegen() =
var xs: seq[Regen]
let a = Regen(x: false, a: Sinn(c: right))
var b = a
xs.add(a)
doAssert b.a.c == right
mainRegen()