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

Make «use 5.036;» respect -X #21431

Merged
merged 2 commits into from
Sep 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion op.c
Original file line number Diff line number Diff line change
Expand Up @@ -7967,7 +7967,7 @@ Perl_utilize(pTHX_ int aver, I32 floor, OP *version, OP *idop, OP *arg)
if (!(PL_hints & HINT_EXPLICIT_STRICT_VARS))
PL_hints |= HINT_STRICT_VARS;

if (shortver >= SHORTVER(5, 35)) {
if (shortver >= SHORTVER(5, 35) && !(PL_dowarn & G_WARN_ALL_MASK)) {
free_and_set_cop_warnings(&PL_compiling, pWARN_ALL);
PL_dowarn |= G_WARN_ONCE;
}
Expand Down
5 changes: 5 additions & 0 deletions pod/perldelta.pod
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,11 @@ Declared references can now be used with C<state> variables. [GH #21351]
Trailing elements in an C<unshift>ed and resized array will now always be
initialized. [GH #21265]

=item * Make C<use 5.036> respect the -X flag

perl's -X flag disables all warnings globally, but «use 5.036» didn't
respect that until now. [GH #21431]

=back

=head1 Known Problems
Expand Down
28 changes: 28 additions & 0 deletions t/run/switches.t
Original file line number Diff line number Diff line change
Expand Up @@ -724,4 +724,32 @@ SWTEST
like( $r, qr/ok/, 'Spaces on the #! line (#30660)' );
}

$r = runperl(
switches => [ '-W', ],
prog => 'my $b = $a + 0',
stderr => 1,
);
is( $r, "Use of uninitialized value \$a in addition (+) at -e line 1.\n", "-W" );

$r = runperl(
switches => [ '-W', ],
prog => 'no warnings; my $b = $a + 0',
stderr => 1,
);
is( $r, "Use of uninitialized value \$a in addition (+) at -e line 1.\n", "-W with no warnings" );

$r = runperl(
switches => [ '-X', ],
prog => 'use warnings; my $b = $a + 0',
stderr => 1,
);
is( $r, "", "-X with use warnings" );

$r = runperl(
switches => [ '-X', ],
prog => 'use 5.036; my $b = $a + 0',
stderr => 1,
);
is( $r, "", "-X with use 5.36" );

done_testing();