From 229a27c40acf932b3db1f40af8300e6481f8a68a Mon Sep 17 00:00:00 2001 From: metagn Date: Fri, 13 Mar 2026 19:01:21 +0300 Subject: [PATCH] properly codegen structs on deref [backport:2.2] (#25600) Follows up #25269, refs #25265. I hit the same bug as #25265 for my own project but #25269 does not fix it, I think because the type in my case is a `tyGenericInst` which does not trigger the generation here. First I thought of skipping abstract type kinds instead of checking for a raw `tyObject`, which fixes my problem. But in general this could maybe also be encountered for `tyTuple` and `tySequence` etc. So I figured it might just be safest to not filter on specific type kinds, ~~which is done now~~ (edit: broke CI). Maybe this has a slight cost on codegen performance though. Edit: Allowing all types failed CI for some reason as commented below, trying skipped type version again. (cherry picked from commit 1a1586a5fb891aeb522a490ccacde3fc02753541) --- compiler/ccgexprs.nim | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/compiler/ccgexprs.nim b/compiler/ccgexprs.nim index 614ac684ae..91265d4c53 100644 --- a/compiler/ccgexprs.nim +++ b/compiler/ccgexprs.nim @@ -769,8 +769,8 @@ proc genDeref(p: BProc, e: PNode, d: var TLoc) = else: a = initLocExprSingleUse(p, e[0]) - if e.typ != nil and e.typ.kind == tyObject: - # bug #23453 #25265 + # bug #23453 #25265 + if e.typ != nil and e.typ.skipTypes(abstractInst).kind == tyObject: discard getTypeDesc(p.module, e.typ) if d.k == locNone: # dest = *a; <-- We do not know that 'dest' is on the heap!