-
Notifications
You must be signed in to change notification settings - Fork 39
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
msgs: more decision making in handleReport #948
Merged
chore-runner
merged 3 commits into
nim-works:devel
from
zerbina:msgs-more-decision-making-in-handleReport
Oct 8, 2023
Merged
msgs: more decision making in handleReport #948
chore-runner
merged 3 commits into
nim-works:devel
from
zerbina:msgs-more-decision-making-in-handleReport
Oct 8, 2023
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Summary ======= * fix hints/warnings promoted to errors always counting towards the maximum error count, even if the hint/warnings is currently disabled * fix disabled warnings and hints being reported by `nimsuggest chk` Details ======= Processing of a `Report` previously worked as follows: 1. `handleReport` pre-processes the report 2. the report is passed to the report hook 3. the hook outputs the report if it determines that the report should be rendered and displayed 4. `handleReport` determines the error handling strategy 5. error handling is performed This has two problems: 1. the responsibility of deciding whether a report should be output is left to the hook, which also means that the hook needs access to all state necessary to make the decision 2. error handling always takes place, even if the report is disabled Report handling is split up, and the responsibilities are shifted: 1. if a report is disabled (`isEnabled` returns false), `handleReport` is a no-op 2. deciding writability is now the responsibility of `handleReport` (i.e., the compiler), with the report hook only invoked if the report is eligible for being displayed 3. computing writability no longer takes into account whether the report is enabled (since writeability is only decided *after* it is know that a report is enabled) 4. `handleReport` now handles the "forcefully enabled" case, by temporarily overriding the `writeln` hook with something that always echoes the message (this mirrors the previous behaviour of the report hook implementations) In short, more responsibility regarding reports shift into a single place (`handleReport`), with the report hook now only being invoked for reports that should be displayed. Centralizing `Report` handling is a step towards eventually removing/replacing `Report`s. Since the the report hook used by `nimsuggest` doesn't consider writeability (`writabilityKind`), this fixes all produced warnings being reported by `chk`, even those that are disabled. Finally, disabled reports no longer triggering error handling fixes disabled warnings promoted to errors being able to abort compilation.
The LineTooLong hints are no longer reported, as it should be.
zerbina
added
bug
Something isn't working
compiler/msgs
Compiler output and diagnostic subsystem: error and warnig reporting, information, debugging
labels
Oct 7, 2023
saem
approved these changes
Oct 8, 2023
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice fix, and also glad it cuts away more of the report hook mess.
/merge |
Merge requested by: @saem Contents after the first section break of the PR description has been removed and preserved below:
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
bug
Something isn't working
compiler/msgs
Compiler output and diagnostic subsystem: error and warnig reporting, information, debugging
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
maximum error count, even if the hint/warning is currently disabled
nimsuggest chk
Details
Processing of a
Report
previously worked as follows:handleReport
pre-processes the reportbe rendered and displayed
handleReport
determines the error handling strategyThis has two problems:
left to the hook, which also means that the hook needs access to all
state necessary to make the decision
Report handling is split up, and the responsibilities are shifted:
isEnabled
returns false),handleReport
is a no-op
handleReport
(i.e., the compiler), with the report hook only invoked if the
report is eligible for being displayed
report is enabled (since writeability is only decided after it is
known that a report is enabled)
handleReport
now handles the "forcefully enabled" case, bytemporarily overriding the
writeln
hook with something that alwaysechoes the message (this mirrors the previous behaviour of the
report hook implementations)
In short, more responsibility regarding reports shift into a single
place (
handleReport
), with the report hook now only being invoked forreports that should be displayed. Centralizing
Report
handling is astep towards eventually removing/replacing
Report
s.Since the the report hook used by
nimsuggest
doesn't considerwriteability (
writabilityKind
), this fixes all produced warningsbeing
reported by
chk
, even those that are disabled.Finally, disabled reports no longer triggering error handling fixes
disabled warnings promoted to errors being able to abort compilation.