Repository navigation
allow "used only once" warnings to be fatal - #21693
Merged
Merged
Conversation
leonerd
reviewed
Dec 6, 2023
| HEKfARG(HvNAME_HEK(stash)), | ||
| HEKfARG(GvNAME_HEK(gv))); | ||
| if (GvONCE_FATAL(gv)) { | ||
| Perl_fatal_warner(aTHX_ packWARN(WARN_ONCE), |
Contributor
There was a problem hiding this comment.
Does this need to use the full Perl_...(aTHX_...) version of a function call? Is the macro generated in embed.h visible here, so this could be just fatal_warner(packWARN...)?
Contributor
Author
There was a problem hiding this comment.
New-fangled varargs macros 馃樀
I've updated both of these.
| HEKfARG(GvNAME_HEK(gv))); | ||
| } | ||
| else { | ||
| Perl_warner(aTHX_ packWARN(WARN_ONCE), |
Comment on lines
+2140
to
+2141
| This outputs a warning as if fatal warnings were enabled. This may | ||
| return in some cases. |
Contributor
There was a problem hiding this comment.
I can't quite follow from these words what it is that the function does. Can you perhaps use more words to describe it?
Contributor
Author
There was a problem hiding this comment.
I've added more words. 馃槃
"used only once" warnings are special, instead of being emitted at the code where the name in question is used, they are emitted during a scan of the symbol table done after parsing has finished. This meant that any FATAL flags set in the COP for the parse point of the name is no longer in scope, so the warnings we emit can't be treated as fatal. To make them behave as FATAL set a new flag on the name if fatal WARN_ONCE warnings are enabled and use that to dispatch the warnings as normal or fatally when we do the symbol table scan. I originally approached the dispatch as fatal or non-fatal by messing around with cop_warnings, but that was dumb, and I went for a much simpler change. Fixes Perl#13814
tonycoz
force-pushed
the
13814-fatal-only-once
branch
from
December 7, 2023 04:03
5d0e799 to
9bb85c7
Compare
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
"used only once" warnings are special, instead of being emitted at the code where the name in question is used, they are emitted during a scan of the symbol table done after parsing has finished.
This meant that any FATAL flags set in the COP for the parse point of the name is no longer in scope, so the warnings we emit can't be treated as fatal.
To make them behave as FATAL set a new flag on the name if fatal WARN_ONCE warnings are enabled and use that to dispatch the warnings as normal or fatally when we do the symbol table scan.
I originally approached the dispatch as fatal or non-fatal by messing around with cop_warnings, but that was dumb, and I went for a much simpler change.
Fixes #13814