Issue deprecation warnings on subsequent use VERSION declarations

This commit is contained in:
Paul "LeoNerd" Evans 2024-02-07 17:19:26 +00:00 committed by Paul Evans
parent 1ebd85eebd
commit 351de214d2
9 changed files with 68 additions and 4 deletions

15
lib/warnings.pm generated
View File

@ -134,6 +134,9 @@ our %Offsets = (
# Warnings Categories added in Perl 5.039002
'deprecated::missing_import_called_with_args'=> 160,
# Warnings Categories added in Perl 5.039008
'deprecated::subsequent_use_version'=> 162,
);
our %Bits = (
@ -143,13 +146,14 @@ our %Bits = (
'closed' => "\x00\x10\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00", # [6]
'closure' => "\x04\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00", # [1]
'debugging' => "\x00\x00\x00\x00\x00\x10\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00", # [22]
'deprecated' => "\x10\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x05\x00\x00\x40\x00\x00\x40\x51\x01", # [2,48,49,63,75,76,78..80]
'deprecated' => "\x10\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x05\x00\x00\x40\x00\x00\x40\x51\x05", # [2,48,49,63,75,76,78..81]
'deprecated::apostrophe_as_package_separator'=> "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x10\x00", # [78]
'deprecated::delimiter_will_be_paired'=> "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00", # [76]
'deprecated::dot_in_inc' => "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x40\x00\x00\x00\x00\x00", # [63]
'deprecated::goto_construct' => "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00", # [48]
'deprecated::missing_import_called_with_args'=> "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01", # [80]
'deprecated::smartmatch' => "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x40\x00", # [79]
'deprecated::subsequent_use_version'=> "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x04", # [81]
'deprecated::unicode_property_name' => "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x04\x00\x00\x00\x00\x00\x00\x00\x00", # [49]
'deprecated::version_downgrade' => "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x40\x00\x00", # [75]
'digit' => "\x00\x00\x00\x00\x00\x00\x00\x40\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00", # [31]
@ -227,13 +231,14 @@ our %DeadBits = (
'closed' => "\x00\x20\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00", # [6]
'closure' => "\x08\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00", # [1]
'debugging' => "\x00\x00\x00\x00\x00\x20\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00", # [22]
'deprecated' => "\x20\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x0a\x00\x00\x80\x00\x00\x80\xa2\x02", # [2,48,49,63,75,76,78..80]
'deprecated' => "\x20\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x0a\x00\x00\x80\x00\x00\x80\xa2\x0a", # [2,48,49,63,75,76,78..81]
'deprecated::apostrophe_as_package_separator'=> "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x20\x00", # [78]
'deprecated::delimiter_will_be_paired'=> "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00", # [76]
'deprecated::dot_in_inc' => "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x80\x00\x00\x00\x00\x00", # [63]
'deprecated::goto_construct' => "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x00\x00\x00\x00\x00\x00\x00", # [48]
'deprecated::missing_import_called_with_args'=> "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02", # [80]
'deprecated::smartmatch' => "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x80\x00", # [79]
'deprecated::subsequent_use_version'=> "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x08", # [81]
'deprecated::unicode_property_name' => "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x08\x00\x00\x00\x00\x00\x00\x00\x00", # [49]
'deprecated::version_downgrade' => "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x80\x00\x00", # [75]
'digit' => "\x00\x00\x00\x00\x00\x00\x00\x80\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00", # [31]
@ -317,8 +322,8 @@ our %NoOp = (
# These are used by various things, including our own tests
our $NONE = "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0";
our $DEFAULT = "\x10\x01\x00\x00\x00\x50\x04\x00\x00\x00\x00\x00\x05\x00\x55\x50\x54\x55\x45\x55\x01"; # [2,4,22,23,25,48,49,56..59,62,63,65..73,75..80]
our $LAST_BIT = 162 ;
our $DEFAULT = "\x10\x01\x00\x00\x00\x50\x04\x00\x00\x00\x00\x00\x05\x00\x55\x50\x54\x55\x45\x55\x05"; # [2,4,22,23,25,48,49,56..59,62,63,65..73,75..81]
our $LAST_BIT = 164 ;
our $BYTES = 21 ;
sub Croaker
@ -933,6 +938,8 @@ The current hierarchy is:
| |
| +- deprecated::smartmatch
| |
| +- deprecated::subsequent_use_version
| |
| +- deprecated::unicode_property_name
| |
| +- deprecated::version_downgrade

4
op.c
View File

@ -8030,6 +8030,10 @@ Perl_utilize(pTHX_ int aver, I32 floor, OP *version, OP *idop, OP *arg)
/* downgrading from >= 5.11 to < 5.11 is now fatal */
if (PL_prevailing_version >= SHORTVER(5, 11) && shortver < SHORTVER(5, 11))
croak("Downgrading a use VERSION declaration to below v5.11 is not permitted");
/* OK let's at least warn */
deprecate_fatal_in(WARN_DEPRECATED__SUBSEQUENT_USE_VERSION, "5.46",
"use VERSION while another use VERSION is in scope");
}
/* If a version >= 5.11.0 is requested, strictures are on by default! */

View File

@ -60,6 +60,18 @@ in deprecation warnings.
Category: "deprecated::unicode_property_name"
=head2 Perl 5.46
=head3 C<use VERSION> while another C<use VERSION> is in scope
A C<use VERSION> declaration has many implicit effects on the surrounding
scope, such as L<strict> and L<feature> flags, or importing L<builtin>
functions. Once you have a C<use VERSION> statement in scope, any other
C<use VERSION> statement is now deprecated since Perl 5.39.8, due to the
increasing complexity of swapping from one prevalent version to another.
Category: "deprecated::subsequent_use_version"
=head2 Perl 5.44
=head3 Calling a missing C<import()> or C<unimport()> method with an argument

View File

@ -7845,6 +7845,30 @@ even if it requests a later version.
subsequent one that calls for a Perl version of at least 5.39 while the first
is visible.
=item use VERSION while another use VERSION is in scope is now deprecated
(W deprecated) Once you have a C<use VERSION> statement in scope, any other
C<use VERSION> statement is now deprecated, due to the increasing complexity
of swapping from one prevalent version to another.
It is suggested that you do not try to mix multiple different version
declarations within the same file as it leads to complex behaviours about the
visibility of features and builtin functions, as well as confusing human
readers.
If it is essential to have different C<use VERSION> declarations in different
regions of the same file, you should surround each one by its own enclosing
scope so the two do not mix.
{
use v5.20;
...
}
{
use v5.36;
...
}
=item Use \x{...} for more than two hex characters in regex; marked by
S<<-- HERE> in m/%s/

View File

@ -85,6 +85,7 @@ our $WARNING_TREE = {
'deprecated::smartmatch' => [ 5.037010, DEFAULT_ON],
'deprecated::missing_import_called_with_args'
=> [ 5.039002, DEFAULT_ON],
'deprecated::subsequent_use_version' => [ 5.039008, DEFAULT_ON],
}],
'void' => [ 5.008, DEFAULT_OFF],
'recursion' => [ 5.008, DEFAULT_OFF],

View File

@ -69,6 +69,8 @@ evalbytes "say 'yes'";
use 5.014;
evalbytes;
EXPECT
use VERSION while another use VERSION is in scope is deprecated, and will become fatal in Perl 5.46 at - line 6.
use VERSION while another use VERSION is in scope is deprecated, and will become fatal in Perl 5.46 at - line 8.
say sub
yes
evalbytes sub
@ -80,6 +82,7 @@ print 'ss' =~ /$sharp_s/i ? "ok\n" : "nok\n";
use v5.14;
print 'ss' =~ /$sharp_s/i ? "ok\n" : "nok\n";
EXPECT
use VERSION while another use VERSION is in scope is deprecated, and will become fatal in Perl 5.46 at - line 5.
nok
ok
########
@ -91,5 +94,6 @@ print eval "use utf8; q|$long_s|" eq "\x{17f}" ? "ok\n" : "nok\n";
use v5.15;
print eval "use utf8; q|$long_s|" eq $long_s ? "ok\n" : "nok\n";
EXPECT
use VERSION while another use VERSION is in scope is deprecated, and will become fatal in Perl 5.46 at - line 6.
ok
ok

View File

@ -2157,3 +2157,9 @@ c
a
d
b
########
use warnings;
use v5.12;
use v5.20;
EXPECT
use VERSION while another use VERSION is in scope is deprecated, and will become fatal in Perl 5.46 at - line 3.

View File

@ -251,6 +251,7 @@ EXPECT
use warnings;
eval 'use 5.006; use 5.10.0';
EXPECT
use VERSION while another use VERSION is in scope is deprecated, and will become fatal in Perl 5.46 at (eval 1) line 1.
########
# SKIP ? !$Config{default_inc_includes_dot}
# NAME check warning for do with no . in @INC

5
warnings.h generated
View File

@ -163,6 +163,10 @@
/* Warnings Categories added in Perl 5.039002 */
#define WARN_DEPRECATED__MISSING_IMPORT_CALLED_WITH_ARGS 80
/* Warnings Categories added in Perl 5.039008 */
#define WARN_DEPRECATED__SUBSEQUENT_USE_VERSION 81
#define WARNsize 21
#define WARN_ALLstring "\125\125\125\125\125\125\125\125\125\125\125\125\125\125\125\125\125\125\125\125\125"
#define WARN_NONEstring "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
@ -358,6 +362,7 @@ category parameters passed.
=for apidoc Amnh||WARN_DEPRECATED__APOSTROPHE_AS_PACKAGE_SEPARATOR
=for apidoc Amnh||WARN_DEPRECATED__SMARTMATCH
=for apidoc Amnh||WARN_DEPRECATED__MISSING_IMPORT_CALLED_WITH_ARGS
=for apidoc Amnh||WARN_DEPRECATED__SUBSEQUENT_USE_VERSION
=cut
*/