diff --git a/op.c b/op.c index 9c90cbe07bc9..4e569dd35c0c 100644 --- a/op.c +++ b/op.c @@ -8086,8 +8086,7 @@ Perl_newAVREF(pTHX_ OP *o) return o; } else if ((o->op_type == OP_RV2AV || o->op_type == OP_PADAV)) { - Perl_ck_warner_d(aTHX_ packWARN(WARN_DEPRECATED), - "Using an array as a reference is deprecated"); + Perl_croak(aTHX_ "Can't use an array as a reference"); } return newUNOP(OP_RV2AV, 0, scalar(o)); } @@ -8113,8 +8112,7 @@ Perl_newHVREF(pTHX_ OP *o) return o; } else if ((o->op_type == OP_RV2HV || o->op_type == OP_PADHV)) { - Perl_ck_warner_d(aTHX_ packWARN(WARN_DEPRECATED), - "Using a hash as a reference is deprecated"); + Perl_croak(aTHX_ "Can't use a hash as a reference"); } return newUNOP(OP_RV2HV, 0, scalar(o)); } diff --git a/pod/perldiag.pod b/pod/perldiag.pod index 67524bd20f5c..2e9165f0858b 100644 --- a/pod/perldiag.pod +++ b/pod/perldiag.pod @@ -1187,6 +1187,18 @@ indicates that such a conversion was attempted. (F) You tried to call perl with the B<-m> switch, but you put something other than "=" after the module name. +=item Can't use a hash as a reference + +(F) You tried to use a hash as a reference, as in +C<< %foo->{"bar"} >> or C<< %$ref->{"hello"} >>. Versions of perl <= 5.6.1 +used to allow this syntax, but shouldn't have. + +=item Can't use an array as a reference + +(F) You tried to use an array as a reference, as in +C<< @foo->[23] >> or C<< @$ref->[99] >>. Versions of perl <= 5.6.1 used to +allow this syntax, but shouldn't have. + =item Can't use anonymous symbol table for method lookup (F) The internal routine that does method lookup was handed a symbol @@ -6434,20 +6446,6 @@ or if you meant this You need to add either braces or blanks to disambiguate. -=item Using a hash as a reference is deprecated - -(D deprecated) You tried to use a hash as a reference, as in -C<< %foo->{"bar"} >> or C<< %$ref->{"hello"} >>. Versions of perl <= 5.6.1 -used to allow this syntax, but shouldn't have. It is now -deprecated, and will be removed in a future version. - -=item Using an array as a reference is deprecated - -(D deprecated) You tried to use an array as a reference, as in -C<< @foo->[23] >> or C<< @$ref->[99] >>. Versions of perl <= 5.6.1 used to -allow this syntax, but shouldn't have. It is now deprecated, -and will be removed in a future version. - =item Using just the first character returned by \N{} in character class in regex; marked by S<<-- HERE> in m/%s/ diff --git a/t/lib/warnings/op b/t/lib/warnings/op index f5fad9c7f3a7..4773aece5a95 100644 --- a/t/lib/warnings/op +++ b/t/lib/warnings/op @@ -300,33 +300,60 @@ syntax error at - line 4, near "[]" Execution of - aborted due to compilation errors. ######## # op.c -my (@foo, %foo); -%main::foo->{"bar"}; -%foo->{"bar"}; -@main::foo->[23]; -@foo->[23]; -$main::foo = {}; %$main::foo->{"bar"}; -$foo = {}; %$foo->{"bar"}; -$main::foo = []; @$main::foo->[34]; -$foo = []; @$foo->[34]; -no warnings 'deprecated'; +my %foo; %main::foo->{"bar"}; +EXPECT +OPTION fatal +Can't use a hash as a reference at - line 3. +######## +# op.c +my %foo; %foo->{"bar"}; +EXPECT +OPTION fatal +Can't use a hash as a reference at - line 3. +######## +# op.c +my @foo; @main::foo->[23]; +EXPECT +OPTION fatal +Can't use an array as a reference at - line 3. +######## +# op.c +my @foo; @foo->[23]; +EXPECT +OPTION fatal +Can't use an array as a reference at - line 3. +######## +# op.c +my %foo; $main::foo = {}; %$main::foo->{"bar"}; +EXPECT +OPTION fatal +Can't use a hash as a reference at - line 3. +######## +# op.c +my %foo; $foo = {}; %$foo->{"bar"}; +EXPECT +OPTION fatal +Can't use a hash as a reference at - line 3. +######## +# op.c +my @foo; $main::foo = []; @$main::foo->[34]; +EXPECT +OPTION fatal +Can't use an array as a reference at - line 3. +######## +# op.c +my @foo; $foo = []; @$foo->[34]; EXPECT -Using a hash as a reference is deprecated at - line 3. -Using a hash as a reference is deprecated at - line 4. -Using an array as a reference is deprecated at - line 5. -Using an array as a reference is deprecated at - line 6. -Using a hash as a reference is deprecated at - line 7. -Using a hash as a reference is deprecated at - line 8. -Using an array as a reference is deprecated at - line 9. -Using an array as a reference is deprecated at - line 10. +OPTION fatal +Can't use an array as a reference at - line 3. ######## # op.c use warnings 'void' ; no warnings 'experimental::smartmatch'; close STDIN ; diff --git a/t/op/kvhslice.t b/t/op/kvhslice.t index ca603174b0df..b30e6314ddbc 100644 --- a/t/op/kvhslice.t +++ b/t/op/kvhslice.t @@ -8,7 +8,7 @@ BEGIN { # use strict; -plan tests => 44; +plan tests => 40; # simple use cases { @@ -162,20 +162,13 @@ plan tests => 44; is (scalar @warn, 0, 'no warning in list context'); } - # deprecated syntax { my $h = \%h; - @warn = (); - ok( eq_array([eval '%$h->{a}'], ['A']), 'works, but deprecated' ); - is (scalar @warn, 1, 'one warning'); - like $warn[0], qr{^Using a hash as a reference is deprecated}, - "correct warning text"; + eval '%$h->{a}'; + like($@, qr/Can't use a hash as a reference/, 'hash reference is error' ); - @warn = (); - ok( eq_array([eval '%$h->{"b","c"}'], [undef]), 'works, but deprecated' ); - is (scalar @warn, 1, 'one warning'); - like $warn[0], qr{^Using a hash as a reference is deprecated}, - "correct warning text"; + eval '%$h->{"b","c"}'; + like($@, qr/Can't use a hash as a reference/, 'hash slice reference is error' ); } }