-
Notifications
You must be signed in to change notification settings - Fork 597
allow "used only once" warnings to be fatal #21693
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
Conversation
gv.c
Outdated
HEKfARG(HvNAME_HEK(stash)), | ||
HEKfARG(GvNAME_HEK(gv))); | ||
if (GvONCE_FATAL(gv)) { | ||
Perl_fatal_warner(aTHX_ packWARN(WARN_ONCE), |
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.
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...)
?
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.
New-fangled varargs macros 😵
I've updated both of these.
gv.c
Outdated
HEKfARG(GvNAME_HEK(gv))); | ||
} | ||
else { | ||
Perl_warner(aTHX_ packWARN(WARN_ONCE), |
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.
Ditto here
util.c
Outdated
This outputs a warning as if fatal warnings were enabled. This may | ||
return in some cases. |
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.
I can't quite follow from these words what it is that the function does. Can you perhaps use more words to describe it?
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.
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
5d0e799
to
9bb85c7
Compare
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.
LGTM
"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