* fixed nimsuggest crash when opening a .nim file, that contain a {.fatal: "msg".} pragma. (#23325) (#23328)

(cherry picked from commit 773c066634)
This commit is contained in:
Nikolay Nikolov
2024-02-24 08:40:18 +02:00
committed by GitHub
parent 3be2514683
commit 22de3ae53e
2 changed files with 17 additions and 1 deletions

View File

@@ -429,7 +429,8 @@ To create a stacktrace, rerun compilation with './koch temp $1 <file>', see $2 f
proc handleError(conf: ConfigRef; msg: TMsgKind, eh: TErrorHandling, s: string, ignoreMsg: bool) =
if msg in fatalMsgs:
if conf.cmd == cmdIdeTools: log(s)
quit(conf, msg)
if conf.cmd != cmdIdeTools or msg != errFatal:
quit(conf, msg)
if msg >= errMin and msg <= errMax or
(msg in warnMin..hintMax and msg in conf.warningAsErrors and not ignoreMsg):
inc(conf.errorCounter)

View File

@@ -0,0 +1,15 @@
{.warning: "I'm a warning!".}
{.error: "I'm an error!".}
{.fatal: "I'm a fatal error!".}
{.error: "I'm an error after fatal error!".}
#[!]#
discard """
$nimsuggest --tester $file
>chk $1
chk;;skUnknown;;;;Hint;;???;;0;;-1;;">> (toplevel): import(dirty): tests/tfatal1.nim [Processing]";;0
chk;;skUnknown;;;;Warning;;$file;;1;;9;;"I\'m a warning! [User]";;0
chk;;skUnknown;;;;Error;;$file;;2;;7;;"I\'m an error!";;0
chk;;skUnknown;;;;Error;;$file;;3;;7;;"fatal error: I\'m a fatal error!";;0
chk;;skUnknown;;;;Error;;$file;;4;;7;;"I\'m an error after fatal error!";;0
"""