From 2a8e4dd977d514ac4e0ecc7e1318275b2d4c886b Mon Sep 17 00:00:00 2001 From: ringabout <43030857+ringabout@users.noreply.github.com> Date: Wed, 25 Feb 2026 20:45:09 +0800 Subject: [PATCH] fixes #25407; SIGSEGV when compiling when with typedesc --- compiler/sem.nim | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/compiler/sem.nim b/compiler/sem.nim index cdda93223a..9c1a541f28 100644 --- a/compiler/sem.nim +++ b/compiler/sem.nim @@ -491,7 +491,11 @@ proc semAfterMacroCall(c: PContext, call, macroResult: PNode, renderTree(result, {renderNoComments})) result = newSymNode(errorSym(c, result)) else: - result.typ = makeTypeDesc(c, typ) + # Replace with a clean nkType node so that complex expressions + # (like `when` statements from template expansion) don't persist + # in the AST with potentially uninitialized children that would + # cause a SIGSEGV during the transform phase's constant folding. + result = newNodeIT(nkType, result.info, makeTypeDesc(c, typ)) #result = symNodeFromType(c, typ, n.info) else: if s.ast[genericParamsPos] != nil and retType.isMetaType: