Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixes #20149; fixes #16762; hintAsError and warningAsError now ignore foreign packages #20151

Merged
merged 8 commits into from
Aug 19, 2022

Conversation

ringabout
Copy link
Member

@ringabout ringabout commented Aug 4, 2022

fixes #20149
fixes #16762

tests/errmsgs/t20149.nim Outdated Show resolved Hide resolved
@ringabout
Copy link
Member Author

ringabout commented Aug 4, 2022

note to future lookup: pre-existing but hintAsError/warningAsError seems not to give a correct exit code which makes testament stop to work.

@ringabout ringabout changed the title fixes #20149; hintAsError and warningAsError now ignore foreign packages fixes #20149; fixes #16762; hintAsError and warningAsError now ignore foreign packages Aug 4, 2022
@PhilippMDoerner
Copy link
Contributor

In terms of feedback:
I just built this branch with koch and used it to compile my project (which is the reason I opened #20149).
It works exactly correct!

When on the branch and compiling with
./koch temp c -d:ssl --hintAsError:XDeclaredButNotUsed --warningAsError:UnusedImport ../nimstoryfont/src/nimstoryfont.nim
or
./koch temp c -d:ssl "--hintAsError[XDeclaredButNotUsed]:on" "--warningAsError[UnusedImport]:on" ../nimstoryfont/src/nimstoryfont.nim

It no longer throws a compiler error in the system.nim or fatal.nim modules, which it previously did!

@ringabout
Copy link
Member Author

Unrelated CI failure, ggplot breaks for a short while.

@ringabout ringabout self-assigned this Aug 5, 2022
@PhilippMDoerner
Copy link
Contributor

Given that it's running through and looking good, is this PR just waiting for somebody else to look over it?

@ringabout
Copy link
Member Author

ringabout commented Aug 7, 2022

Yeah, it is ready for review. Feel free to review. Remember to approve my PR if you think it is fine.

image

@@ -531,8 +531,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:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What meaning does it have for msg in conf.warningAsErrors to be true? What would a boolean that contained the result of that statement be accurately be named like?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe you could expand this test with an unused import to test that in a single go? Would only require e.g. import std/options in the file and --warningAsError:UnusedImport in trunner.nim

Sounds good to me. Feel free to add a test case in the following up prs.

Is there a way to test that the flag correctly prohibits compilation? Or would that be out of scope?

Yeah, there are tests for that. Using compiles should work for simple cases. If you can also go through the trouble of using execCmdEx and compare the outputs. Following-up prs are welcome!

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What meaning does it have for msg in conf.warningAsErrors to be true?

conf.warningAsErrors is a set of TMsgKind enum type. If msg in the conf.warningAsErrors, it means this hints/warnings are enabled for the file and you have already specified that hints/warnings should be errors.

For instance, for a module within the current package, XDeclaredButNotUsed is enabled. If you also specify --hintAsError:XDeclaredButNotUsed is true, in this case XDeclaredButNotUsed is the msg variable, --hintAsError:XDeclaredButNotUsed means XDeclaredButNotUsed is added to conf.warningAsErrors. So the statement "msg in conf.warningAsErrors" is true.

For a foreign package, XDeclaredButNotUsed is not enabled by default. Even if --hintAsError:XDeclaredButNotUsed is specified, the statement "msg in conf.warningAsErrors" is false.

@@ -249,12 +249,18 @@ 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}"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll still approve this, but would like to note that this will break if nim or nimcache are not properly escaped.

@Varriount Varriount merged commit 641381e into devel Aug 19, 2022
@Varriount Varriount deleted the pr_warnings branch August 19, 2022 20:24
@github-actions
Copy link
Contributor

Thanks for your hard work on this PR!
The lines below are statistics of the Nim compiler built from 641381e

Hint: mm: orc; threads: on; opt: speed; options: -d:release
163662 lines; 12.332s; 841.645MiB peakmem

capocasa pushed a commit to capocasa/Nim that referenced this pull request Mar 31, 2023
…Error now ignore foreign packages (nim-lang#20151)

* fixes nim-lang#20149;  hintAsError/warningAsError ignores foreign packages

* add changelog

* fixes the test

* remove

* fixes tests again

* fix

* I'm careless

Co-authored-by: xflywind <[email protected]>
narimiran pushed a commit that referenced this pull request Apr 24, 2023
… foreign packages (#20151)

* fixes #20149;  hintAsError/warningAsError ignores foreign packages

* add changelog

* fixes the test

* remove

* fixes tests again

* fix

* I'm careless

Co-authored-by: xflywind <[email protected]>
(cherry picked from commit 641381e)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants