Skip to content

Commit

Permalink
undeprecate switch and smartmatch
Browse files Browse the repository at this point in the history
The deprecation warnings don't appear to have had any tests.
  • Loading branch information
tonycoz authored and ap committed Feb 16, 2025
1 parent 6868eea commit 2dd81b7
Show file tree
Hide file tree
Showing 9 changed files with 179 additions and 235 deletions.
346 changes: 170 additions & 176 deletions lib/warnings.pm

Large diffs are not rendered by default.

9 changes: 0 additions & 9 deletions pod/perldeprecation.pod
Original file line number Diff line number Diff line change
Expand Up @@ -71,15 +71,6 @@ Category: "deprecated::subsequent_use_version"

=head2 Perl 5.42

=head3 Smartmatch

Smartmatch is now seen as a failed experiment and was marked as deprecated
in Perl 5.37.10. This includes the C<when> and C<given> keywords, as well
as the smartmatch operator C<~~>. The feature will be removed entirely in the
Perl 5.42.0 production release.

Category: "deprecated::smartmatch"

=head3 Goto Block Construct

C<goto LABEL;> will produce a deprecated warning when jumping into the body
Expand Down
22 changes: 0 additions & 22 deletions pod/perldiag.pod
Original file line number Diff line number Diff line change
Expand Up @@ -2775,12 +2775,6 @@ L<perlfunc/getsockopt>.
arguments are provided in key/value pairs, with the keys being one
of C<input>, C<output> or C<detail>, followed by a boolean.

=item given is deprecated

(D deprecated::smartmatch) C<given> depends on smartmatch, which is
deprecated. It will be removed in Perl 5.42. See the explanation under
L<perlsyn/Experimental Details on given and when>.

=item Global symbol "%s" requires explicit package name (did you forget to
declare "my %s"?)

Expand Down Expand Up @@ -6219,14 +6213,6 @@ so there can't be any left to fill later parameters.
overload it: Perl refuses to use the object's underlying structure
for the smart match.

=item Smartmatch is deprecated

(D deprecated::smartmatch) This warning is emitted if you
use the smartmatch (C<~~>) operator. This is a deprecated
feature. Particularly, its behavior is noticed for being
unnecessarily complex and unintuitive, and it will be removed
in Perl 5.42.

=item Sorry, hash keys must be smaller than 2**31 bytes

(F) You tried to create a hash containing a very large key, where "very
Expand Down Expand Up @@ -8237,14 +8223,6 @@ but in actual fact, you got

So put in parentheses to say what you really mean.

=item when is deprecated

(D deprecated::smartmatch) C<when> depends on smartmatch, which is
deprecated. Additionally, it has several special cases that may
not be immediately obvious, and it will be removed in Perl 5.42.
See the explanation
under L<perlsyn/Experimental Details on given and when>.

=item Wide character in %s

(S utf8) Perl met a wide character (ordinal >255) when it wasn't
Expand Down
4 changes: 2 additions & 2 deletions regen/warnings.pl
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
#
# This script is normally invoked from regen.pl.

$VERSION = '1.72';
$VERSION = '1.73';

BEGIN {
require './regen/regen_lib.pl';
Expand Down Expand Up @@ -80,7 +80,6 @@ BEGIN
'deprecated::dot_in_inc' => [ 5.025011, DEFAULT_ON],
'deprecated::version_downgrade' => [ 5.035009, DEFAULT_ON],
'deprecated::delimiter_will_be_paired' => [ 5.035010, DEFAULT_ON],
'deprecated::smartmatch' => [ 5.037010, DEFAULT_ON],
'deprecated::missing_import_called_with_args'
=> [ 5.039002, DEFAULT_ON],
'deprecated::subsequent_use_version' => [ 5.039008, DEFAULT_ON],
Expand Down Expand Up @@ -188,6 +187,7 @@ BEGIN
# the experiments were successful (or abandonned),
# so no warning bit is needed anymore
my %NO_BIT_FOR = map { ( uc $_ => 1, $_ => 1 ) } qw(
deprecated::smartmatch
experimental::lexical_subs
experimental::postderef
experimental::signatures
Expand Down
4 changes: 0 additions & 4 deletions t/lib/feature/smartmatch
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ __END__
my @x = qw(a b c);
my $y = "b" ~~ @x;
EXPECT
Smartmatch is deprecated at - line 2.
########
# NAME explicit disable
no feature "smartmatch";
Expand All @@ -21,15 +20,13 @@ use feature "smartmatch";
my @x = qw(a b c);
my $y = "b" ~~ @x;
EXPECT
Smartmatch is deprecated at - line 3.
########
# NAME explicit disable then enable
no feature "smartmatch";
use feature "smartmatch";
my @x = qw(a b c);
my $y = "b" ~~ @x;
EXPECT
Smartmatch is deprecated at - line 4.
########
# NAME implicit disable
use v5.41;
Expand All @@ -46,4 +43,3 @@ use feature "smartmatch";
my @x = qw(a b c);
my $y = "b" ~~ @x;
EXPECT
Smartmatch is deprecated at - line 4.
1 change: 0 additions & 1 deletion t/op/smartmatch.t
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ BEGIN {
use strict;
use warnings;
no warnings 'uninitialized';
no warnings 'deprecated'; # smartmatch is deprecated and will be removed in 5.042

++$|;

Expand Down
1 change: 0 additions & 1 deletion t/op/switch.t
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ BEGIN {

use strict;
use warnings;
no warnings 'deprecated';

plan tests => 197;

Expand Down
8 changes: 0 additions & 8 deletions toke.c
Original file line number Diff line number Diff line change
Expand Up @@ -6780,9 +6780,6 @@ yyl_tilde(pTHX_ char *s)
if (!PL_lex_allbrackets && PL_lex_fakeeof >= LEX_FAKEEOF_COMPARE)
TOKEN(0);
s += 2;
Perl_ck_warner_d(aTHX_
packWARN(WARN_DEPRECATED__SMARTMATCH),
"Smartmatch is deprecated");
NCEop(OP_SMARTMATCH);
}
s++;
Expand Down Expand Up @@ -8311,8 +8308,6 @@ yyl_word_or_keyword(pTHX_ char *s, STRLEN len, I32 key, I32 orig_keyword, struct

case KEY_given:
pl_yylval.ival = CopLINE(PL_curcop);
Perl_ck_warner_d(aTHX_ packWARN(WARN_DEPRECATED__SMARTMATCH),
"given is deprecated");
OPERATOR(KW_GIVEN);

case KEY_glob:
Expand Down Expand Up @@ -8822,9 +8817,6 @@ yyl_word_or_keyword(pTHX_ char *s, STRLEN len, I32 key, I32 orig_keyword, struct
if (!PL_lex_allbrackets && PL_lex_fakeeof >= LEX_FAKEEOF_NONEXPR)
return REPORT(0);
pl_yylval.ival = CopLINE(PL_curcop);
Perl_ck_warner_d(aTHX_
packWARN(WARN_DEPRECATED__SMARTMATCH),
"when is deprecated");
OPERATOR(KW_WHEN);

case KEY_while:
Expand Down
19 changes: 7 additions & 12 deletions warnings.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 2dd81b7

Please sign in to comment.