fixes #24974; SIGSEGV when raising Defect/doAssert (#24985)

fixes #24974

requires `result` initializations when encountering unreachable code
(e.g. `quit`)

(cherry picked from commit 638a8bf84d)
This commit is contained in:
ringabout
2025-06-10 20:12:12 +08:00
committed by narimiran
parent 11fc6962ae
commit 7fdbdb2f20
2 changed files with 25 additions and 1 deletions

View File

@@ -1150,7 +1150,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..<n.safeLen: