mirror of
https://github.com/nim-lang/Nim.git
synced 2026-04-25 16:53:59 +00:00
* fixes #20149; hintAsError/warningAsError ignores foreign packages
* add changelog
* fixes the test
* remove
* fixes tests again
* fix
* I'm careless
Co-authored-by: xflywind <43030857+xflywind@users.noreply.github.com>
(cherry picked from commit 641381e3d4)
This commit is contained in:
@@ -100,7 +100,7 @@
|
||||
- `nim` can now compile version 1.4.0 as follows: `nim c --lib:lib --stylecheck:off compiler/nim`,
|
||||
without requiring `-d:nimVersion140` which is now a noop.
|
||||
|
||||
- `--styleCheck` now only applies to the current package.
|
||||
- `--styleCheck`, `--hintAsError` and `--warningAsError` now only applies to the current package.
|
||||
|
||||
|
||||
## Tool changes
|
||||
|
||||
@@ -414,12 +414,12 @@ To create a stacktrace, rerun compilation with './koch temp $1 <file>', see $2 f
|
||||
[conf.command, "intern.html#debugging-the-compiler".createDocLink], conf.unitSep)
|
||||
quit 1
|
||||
|
||||
proc handleError(conf: ConfigRef; msg: TMsgKind, eh: TErrorHandling, s: string) =
|
||||
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 msg >= errMin and msg <= errMax or
|
||||
(msg in warnMin..hintMax and msg in conf.warningAsErrors):
|
||||
(msg in warnMin..hintMax and msg in conf.warningAsErrors and not ignoreMsg):
|
||||
inc(conf.errorCounter)
|
||||
conf.exitcode = 1'i8
|
||||
if conf.errorCounter >= conf.errorMax:
|
||||
@@ -527,8 +527,7 @@ proc liMessage*(conf: ConfigRef; info: TLineInfo, msg: TMsgKind, arg: string,
|
||||
of warnMin..warnMax:
|
||||
sev = Severity.Warning
|
||||
ignoreMsg = not conf.hasWarn(msg)
|
||||
if msg in conf.warningAsErrors:
|
||||
ignoreMsg = false
|
||||
if not ignoreMsg and msg in conf.warningAsErrors:
|
||||
title = ErrorTitle
|
||||
else:
|
||||
title = WarningTitle
|
||||
@@ -538,8 +537,7 @@ proc liMessage*(conf: ConfigRef; info: TLineInfo, msg: TMsgKind, arg: string,
|
||||
of hintMin..hintMax:
|
||||
sev = Severity.Hint
|
||||
ignoreMsg = not conf.hasHint(msg)
|
||||
if msg in conf.warningAsErrors:
|
||||
ignoreMsg = false
|
||||
if not ignoreMsg and msg in conf.warningAsErrors:
|
||||
title = ErrorTitle
|
||||
else:
|
||||
title = HintTitle
|
||||
@@ -565,7 +563,7 @@ proc liMessage*(conf: ConfigRef; info: TLineInfo, msg: TMsgKind, arg: string,
|
||||
" compiler msg initiated here", KindColor,
|
||||
KindFormat % $hintMsgOrigin,
|
||||
resetStyle, conf.unitSep)
|
||||
handleError(conf, msg, eh, s)
|
||||
handleError(conf, msg, eh, s, ignoreMsg)
|
||||
if msg in fatalMsgs:
|
||||
# most likely would have died here but just in case, we restore state
|
||||
conf.m.errorOutputs = errorOutputsOld
|
||||
|
||||
2
tests/misc/m20149.nim
Normal file
2
tests/misc/m20149.nim
Normal file
@@ -0,0 +1,2 @@
|
||||
let x = 12
|
||||
echo x
|
||||
@@ -249,6 +249,11 @@ sub/mmain.idx""", context
|
||||
let cmd = fmt"{nim} r -b:cpp --hints:off --nimcache:{nimcache} --warningAsError:ProveInit {file}"
|
||||
check execCmdEx(cmd) == ("witness\n", 0)
|
||||
|
||||
block: # bug #20149
|
||||
let file = testsDir / "misc/m20149.nim"
|
||||
let cmd = fmt"{nim} r --hints:off --nimcache:{nimcache} --hintAsError:XDeclaredButNotUsed {file}"
|
||||
check execCmdEx(cmd) == ("12\n", 0)
|
||||
|
||||
block: # config.nims, nim.cfg, hintConf, bug #16557
|
||||
let cmd = fmt"{nim} r --hint:all:off --hint:conf tests/newconfig/bar/mfoo.nim"
|
||||
let (outp, exitCode) = execCmdEx(cmd, options = {poStdErrToStdOut})
|
||||
|
||||
Reference in New Issue
Block a user