From 638a8bf84d35c6be54cd7e4b4642ce77ae83da39 Mon Sep 17 00:00:00 2001 From: ringabout <43030857+ringabout@users.noreply.github.com> Date: Tue, 10 Jun 2025 20:12:12 +0800 Subject: [PATCH] fixes #24974; SIGSEGV when raising Defect/doAssert (#24985) fixes #24974 requires `result` initializations when encountering unreachable code (e.g. `quit`) --- compiler/cgen.nim | 4 +++- tests/errmsgs/t24974.nim | 22 ++++++++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 tests/errmsgs/t24974.nim diff --git a/compiler/cgen.nim b/compiler/cgen.nim index 39be098663..8bd72d49b2 100644 --- a/compiler/cgen.nim +++ b/compiler/cgen.nim @@ -1234,7 +1234,9 @@ proc allPathsAsgnResult(p: BProc; n: PNode): InitResultEnum = else: allPathsInBranch(n[i].lastSon) of nkCallKinds: - if canRaiseDisp(p, n[0]): + if canRaiseDisp(p, n[0]) or + (n[0].kind == nkSym and sfNoReturn in n[0].sym.flags): + # requires initializations when encountering unreachable code result = InitRequired else: for i in 0..