From 3cbda905e52b3bbfe2c051bc8e0150d4b66cf104 Mon Sep 17 00:00:00 2001 From: ringabout <43030857+ringabout@users.noreply.github.com> Date: Tue, 7 Apr 2026 16:00:04 +0800 Subject: [PATCH] The fix adds a guard: when d.k == locExpr and the destination type differs from the constructor type (inheritance/subtyping), a temporary is still used so that genAssignment can perform the proper type-tag and slicing checks. --- compiler/ccgexprs.nim | 1 + 1 file changed, 1 insertion(+) diff --git a/compiler/ccgexprs.nim b/compiler/ccgexprs.nim index 414a05a70a..3009223925 100644 --- a/compiler/ccgexprs.nim +++ b/compiler/ccgexprs.nim @@ -1893,6 +1893,7 @@ proc genObjConstr(p: BProc, e: PNode, d: var TLoc) = var useTemp = isRef or (d.k notin {locTemp,locLocalVar,locGlobalVar,locParam,locField,locExpr}) or + (d.k == locExpr and d.lode.typ != nil and not sameType(d.lode.typ.skipTypes(abstractInst), t)) or (isPartOf(d.lode, e) != arNo) var tmp: TLoc = default(TLoc)