# no attribute list
my $pi = 4;
####
-# := empty attribute list
+# SKIP ?$] > 5.013006 && ":= is now a syntax error"
+# := treated as an empty attribute list
no warnings;
my $pi := 4;
>>>>
=head1 Incompatible Changes
-XXX For a release on a stable branch, this section aspires to be:
+=head2 Attempting to use C<:=> as an empty attribute list is now a syntax error
- There are no changes intentionally incompatible with 5.XXX.XXX. If any
- exist, they are bugs and reports are welcome.
+Previously C<my $pi := 4;> was exactly equivalent to C<my $pi : = 4;>,
+with the C<:> being treated as the start of an attribute list, ending before
+the C<=>. The use of C<:=> to mean C<: => was deprecated in 5.12.0, and is now
+a syntax error. This will allow the future use of C<:=> as a new token.
-[ List each incompatible change as a =head2 entry ]
+We find no Perl 5 code on CPAN using this construction, outside the core's
+tests for it, so we believe that this change will have very little impact on
+real-world codebases.
+
+If it is absolutely necessary to have empty attribute lists (for example,
+because of a code generator) then avoid the warning by adding a space
+before the C<=>.
=head1 Deprecations
use the /g modifier. Currently, /c is meaningful only when /g is
used. (This may change in the future.)
-=item Use of := for an empty attribute list is deprecated
+=item Use of := for an empty attribute list is not allowed
-(D deprecated) The construction C<my $x := 42> currently
-parses correctly in perl, being equivalent to C<my $x : = 42>
-(applying an empty attribute list to C<$x>). This useless
-construct is now deprecated, so C<:=> can be reclaimed as a new
-operator in the future.
+(F) The construction C<my $x := 42> used to parse as equivalent to
+C<my $x : = 42> (applying an empty attribute list to C<$x>).
+This construct was deprecated in 5.12.0, and has now been made a syntax
+error, so C<:=> can be reclaimed as a new operator in the future.
+
+If you need an empty attribute list, for example in a code generator, add
+a space before the C<=>.
=item Use of ?PATTERN? without explicit operator is deprecated
Possible unintended interpolation of $\ in regex at - line 5.
########
# toke.c
-use feature 'state';
-# This one is fine as an empty attribute list
-my $holy_Einstein : = '';
-# This one is deprecated
-my $krunch := 4;
-our $FWISK_FWISK_FWIZZACH_FWACH_ZACHITTY_ZICH_SHAZZATZ_FWISK := '';
-state $thump := 'Trumpets';
-# Lather rinse repeat in my usual obsessive style
-my @holy_perfect_pitch : = ();
-my @zok := ();
-our @GUKGUK := ();
-# state @widget_mark := ();
-my %holy_seditives : = ();
-my %bang := ();
-our %GIGAZING := ();
-# state %hex := ();
-no warnings 'deprecated';
-my $holy_giveaways : = '';
-my $eee_yow := [];
-our $TWOYYOYYOING_THUK_UGH := 1 == 1;
-state $octothorn := 'Tinky Winky';
-my @holy_Taj_Mahal : = ();
-my @touche := ();
-our @PLAK_DAK_THUK_FRIT := ();
-# state @hash_mark := ();
-my %holy_priceless_collection_of_Etruscan_snoods : = ();
-my %wham_eth := ();
-our %THWUK := ();
-# state %octalthorpe := ();
-use warnings;
-my $holy_sewer_pipe : = '';
-my $thunk := undef;
-our $BLIT := time;
-state $crunch := 'Laa Laa';
-my @glurpp := ();
-my @holy_harem : = ();
-our @FABADAP := ();
-# state @square := ();
-my %holy_pin_cushions : = ();
-my %swoosh := ();
-our %RRRRR := ();
-# state %scratchmark := ();
-EXPECT
-Use of := for an empty attribute list is deprecated at - line 6.
-Use of := for an empty attribute list is deprecated at - line 7.
-Use of := for an empty attribute list is deprecated at - line 8.
-Use of := for an empty attribute list is deprecated at - line 11.
-Use of := for an empty attribute list is deprecated at - line 12.
-Use of := for an empty attribute list is deprecated at - line 15.
-Use of := for an empty attribute list is deprecated at - line 16.
-Use of := for an empty attribute list is deprecated at - line 33.
-Use of := for an empty attribute list is deprecated at - line 34.
-Use of := for an empty attribute list is deprecated at - line 35.
-Use of := for an empty attribute list is deprecated at - line 36.
-Use of := for an empty attribute list is deprecated at - line 38.
-Use of := for an empty attribute list is deprecated at - line 41.
-Use of := for an empty attribute list is deprecated at - line 42.
-########
-# toke.c
use warnings 'syntax' ;
my $a = "\o";
my $a = "\o{";
use warnings;
-plan 92;
-
$SIG{__WARN__} = sub { die @_ };
sub eval_ok ($;$) {
$c=undef; eval 'sub t5 :Foo { }';
main::ok $c == \&{"t5"} && $c == $t5b && $c == $t5a;
}
+
+my @tests = grep {/^[^#]/} split /\n/, <<'EOT';
+# This one is fine as an empty attribute list
+my $holy_Einstein : = '';
+# This one is deprecated
+my $krunch := 4;
+our $FWISK_FWISK_FWIZZACH_FWACH_ZACHITTY_ZICH_SHAZZATZ_FWISK := '';
+state $thump := 'Trumpets';
+# Lather rinse repeat in my usual obsessive style
+my @holy_perfect_pitch : = ();
+my @zok := ();
+our @GUKGUK := ();
+# state @widget_mark := ();
+my %holy_seditives : = ();
+my %bang := ();
+our %GIGAZING := ();
+# state %hex := ();
+my $holy_giveaways : = '';
+my $eee_yow := [];
+our $TWOYYOYYOING_THUK_UGH := 1 == 1;
+state $octothorn := 'Tinky Winky';
+my @holy_Taj_Mahal : = ();
+my @touche := ();
+our @PLAK_DAK_THUK_FRIT := ();
+# state @hash_mark := ();
+my %holy_priceless_collection_of_Etruscan_snoods : = ();
+my %wham_eth := ();
+our %THWUK := ();
+# state %octalthorpe := ();
+my $holy_sewer_pipe : = '';
+my $thunk := undef;
+our $BLIT := time;
+state $crunch := 'Laa Laa';
+my @glurpp := ();
+my @holy_harem : = ();
+our @FABADAP := ();
+# state @square := ();
+my %holy_pin_cushions : = ();
+my %swoosh := ();
+our %RRRRR := ();
+# state %scratchmark := ();
+EOT
+
+foreach my $test (@tests) {
+ use feature 'state';
+ eval $test;
+ if ($test =~ /:=/) {
+ like $@, qr/Use of := for an empty attribute list is not allowed/,
+ "Parse error for q{$test}";
+ } else {
+ is $@, '', "No error for q{$test}";
+ }
+}
+
+done_testing();
break;
PL_bufptr = s; /* update in case we back off */
if (*s == '=') {
- deprecate(":= for an empty attribute list");
+ Perl_croak(aTHX_
+ "Use of := for an empty attribute list is not allowed");
}
goto grabattrs;
case XATTRBLOCK: