mirror of
https://github.com/nim-lang/Nim.git
synced 2026-07-28 03:16:32 +00:00
fixes result requires explicit initialization on noReturn code (#22717)
fixes #21615; fixes #16735 It also partially fixes | #22673, though It still gives 'baseless' warnings.
This commit is contained in:
@@ -1556,7 +1556,7 @@ proc trackProc*(c: PContext; s: PSym, body: PNode) =
|
||||
strictDefs in c.features) and
|
||||
s.kind in {skProc, skFunc, skConverter, skMethod} and s.magic == mNone:
|
||||
var res = s.ast[resultPos].sym # get result symbol
|
||||
if res.id notin t.init:
|
||||
if res.id notin t.init and breaksBlock(body) != bsNoReturn:
|
||||
if tfRequiresInit in s.typ[0].flags:
|
||||
localError(g.config, body.info, "'$1' requires explicit initialization" % "result")
|
||||
else:
|
||||
|
||||
Reference in New Issue
Block a user