-
Notifications
You must be signed in to change notification settings - Fork 553
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
constant pragma doesn't warn on redefinition of a list constant #20742
Labels
Comments
|
I've reproduced this and I see the cause. While reviewing the code I found a related problem: Both that and the reported issue are core bugs rather than bugs in constant.pm |
tonycoz
added a commit
to tonycoz/perl5
that referenced
this issue
Feb 1, 2023
The code in report_redefined_cv() would check whether the old constant and the new constant were the same SV to avoid warning on duplicate imports of the same constant. Since both gv_setref() and report_redefined_cv() used cv_const_sv() to fetch the constant SV, which returns NULL for an AV based constant sub, the check for the equivalent SV would compare NULL to NULL and report_redefined_cv() would return early. Additional checks were required further down to prevent sv_cmp() being called on AVs. The check for simple SV's allow redefinition of constant subs if the new value string compares the same as the old value. The AV check does not try to allow that. Fixed Perl#20742
tonycoz
added a commit
that referenced
this issue
Feb 8, 2023
The code in report_redefined_cv() would check whether the old constant and the new constant were the same SV to avoid warning on duplicate imports of the same constant. Since both gv_setref() and report_redefined_cv() used cv_const_sv() to fetch the constant SV, which returns NULL for an AV based constant sub, the check for the equivalent SV would compare NULL to NULL and report_redefined_cv() would return early. Additional checks were required further down to prevent sv_cmp() being called on AVs. The check for simple SV's allow redefinition of constant subs if the new value string compares the same as the old value. The AV check does not try to allow that. Fixed #20742
pjacklam
pushed a commit
to pjacklam/perl5
that referenced
this issue
May 20, 2023
The code in report_redefined_cv() would check whether the old constant and the new constant were the same SV to avoid warning on duplicate imports of the same constant. Since both gv_setref() and report_redefined_cv() used cv_const_sv() to fetch the constant SV, which returns NULL for an AV based constant sub, the check for the equivalent SV would compare NULL to NULL and report_redefined_cv() would return early. Additional checks were required further down to prevent sv_cmp() being called on AVs. The check for simple SV's allow redefinition of constant subs if the new value string compares the same as the old value. The AV check does not try to allow that. Fixed Perl#20742
pjacklam
pushed a commit
to pjacklam/perl5
that referenced
this issue
May 20, 2023
The code in report_redefined_cv() would check whether the old constant and the new constant were the same SV to avoid warning on duplicate imports of the same constant. Since both gv_setref() and report_redefined_cv() used cv_const_sv() to fetch the constant SV, which returns NULL for an AV based constant sub, the check for the equivalent SV would compare NULL to NULL and report_redefined_cv() would return early. Additional checks were required further down to prevent sv_cmp() being called on AVs. The check for simple SV's allow redefinition of constant subs if the new value string compares the same as the old value. The AV check does not try to allow that. Fixed Perl#20742
khwilliamson
pushed a commit
to khwilliamson/perl5
that referenced
this issue
Jul 10, 2023
The code in report_redefined_cv() would check whether the old constant and the new constant were the same SV to avoid warning on duplicate imports of the same constant. Since both gv_setref() and report_redefined_cv() used cv_const_sv() to fetch the constant SV, which returns NULL for an AV based constant sub, the check for the equivalent SV would compare NULL to NULL and report_redefined_cv() would return early. Additional checks were required further down to prevent sv_cmp() being called on AVs. The check for simple SV's allow redefinition of constant subs if the new value string compares the same as the old value. The AV check does not try to allow that. Fixed Perl#20742
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Module: constant
Description
Redefining a list constant does not produce a warning.
Steps to Reproduce
This redefinition of a scalar constant warns:
But this redefinition of a list one doesn't:
Expected behavior
I expected to see a warning when redefining the list constant.
Perl configuration
The text was updated successfully, but these errors were encountered: