From: Robin Houston Date: Tue, 8 May 2001 19:38:00 +0000 (+0100) Subject: [PATCH op.c] Deprecate %x->{'foo'}, @y->[23] etc X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=a1063b2d347f61fd47f71876da72ed835b315f8a;p=p5sagit%2Fp5-mst-13.2.git [PATCH op.c] Deprecate %x->{'foo'}, @y->[23] etc Date: Tue, 8 May 2001 19:38:00 +0100 Message-ID: <20010508193800.A4389@penderel> Subject: Re: [PATCH op.c] Deprecate %x->{'foo'}, @y->[23] etc From: Robin Houston Date: Tue, 8 May 2001 20:03:57 +0100 Message-ID: <20010508200357.A4614@penderel> Subject: Re: [PATCH op.c] Deprecate %x->{'foo'}, @y->[23] etc From: Robin Houston Date: Wed, 9 May 2001 00:12:05 +0100 Message-ID: <20010509001205.A18521@puffinry.freeserve.co.uk> p4raw-id: //depot/perl@10043 --- diff --git a/op.c b/op.c index 19045f5..e0ca887 100644 --- a/op.c +++ b/op.c @@ -5210,6 +5210,11 @@ Perl_newAVREF(pTHX_ OP *o) o->op_ppaddr = PL_ppaddr[OP_PADAV]; return o; } + else if ((o->op_type == OP_RV2AV || o->op_type == OP_PADAV) + && ckWARN(WARN_DEPRECATED)) { + Perl_warner(aTHX_ WARN_DEPRECATED, + "Using an array as a reference is deprecated"); + } return newUNOP(OP_RV2AV, 0, scalar(o)); } @@ -5229,6 +5234,11 @@ Perl_newHVREF(pTHX_ OP *o) o->op_ppaddr = PL_ppaddr[OP_PADHV]; return o; } + else if ((o->op_type == OP_RV2HV || o->op_type == OP_PADHV) + && ckWARN(WARN_DEPRECATED)) { + Perl_warner(aTHX_ WARN_DEPRECATED, + "Using a hash as a reference is deprecated"); + } return newUNOP(OP_RV2HV, 0, scalar(o)); } diff --git a/pod/perldiag.pod b/pod/perldiag.pod index cd32d72..7b69b63 100644 --- a/pod/perldiag.pod +++ b/pod/perldiag.pod @@ -2751,7 +2751,7 @@ could be a potential Year 2000 problem. =item pragma "attrs" is deprecated, use "sub NAME : ATTRS" instead -(W deprecated) You have written something like this: +(D deprecated) You have written something like this: sub doit { @@ -3812,6 +3812,19 @@ usually optimized into C<"that " . $foo>, and the warning will refer to the C operator, even though there is no C<.> in your program. +=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 Value of %s can be "0"; test with defined() (W misc) In a conditional expression, you used , <*> (glob), diff --git a/t/pragma/overload.t b/t/pragma/overload.t index b310530..d075062 100755 --- a/t/pragma/overload.t +++ b/t/pragma/overload.t @@ -494,7 +494,7 @@ test($c, "bareword"); # 135 sub STORE { my $obj = shift; $#$obj = 1; - @$obj->[0,1] = ('=', shift); + $obj->[1] = shift; } } @@ -615,7 +615,7 @@ test($c, "bareword"); # 135 sub STORE { my $obj = shift; $#$obj = 1; - @$obj->[0,1] = ('=', shift); + $obj->[1] = shift; } } diff --git a/t/pragma/warn/op b/t/pragma/warn/op index b4b8e4e..2f847ad 100644 --- a/t/pragma/warn/op +++ b/t/pragma/warn/op @@ -205,6 +205,36 @@ EXPECT Use of implicit split to @_ is deprecated at - line 3. ######## # op.c +use warnings 'deprecated'; +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'; +%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]; +EXPECT +Using a hash as a reference is deprecated at - line 4. +Using a hash as a reference is deprecated at - line 5. +Using an array as a reference is deprecated at - line 6. +Using an array as a reference is deprecated at - line 7. +Using a hash as a reference is deprecated at - line 8. +Using a hash as a reference is deprecated at - line 9. +Using an array as a reference is deprecated at - line 10. +Using an array as a reference is deprecated at - line 11. +######## +# op.c use warnings 'void' ; close STDIN ; 1 x 3 ; # OP_REPEAT # OP_GVSV