mirror of
https://github.com/nim-lang/Nim.git
synced 2026-04-19 22:10:33 +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:
@@ -62,3 +62,30 @@ block:
|
||||
raise newException(ValueError, "unreachable")
|
||||
|
||||
discard test(true)
|
||||
|
||||
# bug #21615
|
||||
# bug #16735
|
||||
|
||||
block:
|
||||
type Test {.requiresInit.} = object
|
||||
id: int
|
||||
|
||||
proc bar(): int =
|
||||
raise newException(CatchableError, "error")
|
||||
|
||||
proc test(): Test =
|
||||
raise newException(CatchableError, "")
|
||||
|
||||
template catchError(body) =
|
||||
var done = false
|
||||
try:
|
||||
body
|
||||
except CatchableError:
|
||||
done = true
|
||||
doAssert done
|
||||
|
||||
catchError:
|
||||
echo test()
|
||||
|
||||
catchError:
|
||||
echo bar()
|
||||
|
||||
Reference in New Issue
Block a user