From: Nicholas Clark Date: Sun, 12 Apr 2009 11:47:27 +0000 (+0100) Subject: Deprecate use of the attribute :locked on subroutines. X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=8e5dadda1c1c201168c358a10e1073814c1cae6b;p=p5sagit%2Fp5-mst-13.2.git Deprecate use of the attribute :locked on subroutines. --- diff --git a/ext/B/t/deparse.t b/ext/B/t/deparse.t index 2f0f436..4024c0b 100644 --- a/ext/B/t/deparse.t +++ b/ext/B/t/deparse.t @@ -215,12 +215,8 @@ $test /= 2 if ++$test; } #### # 8 -{ - my $test = sub : locked method { - my $x; - } - ; -} +# Was sub : locked method { ... } +# This number could be re-used. #### # 9 { diff --git a/t/lib/warnings/toke b/t/lib/warnings/toke index 04c41d5..e5ca400 100644 --- a/t/lib/warnings/toke +++ b/t/lib/warnings/toke @@ -848,10 +848,23 @@ EXPECT ######## # toke.c our $foo :unique; +sub pam :locked; +sub glipp :locked { +} +sub whack_eth ($) : locked { +} use warnings 'deprecated'; our $bar :unique; +sub zapeth :locked; +sub ker_plop :locked { +} +sub swa_a_p ($) : locked { +} EXPECT -Use of :unique is deprecated at - line 4. +Use of :unique is deprecated at - line 9. +Use of :locked is deprecated at - line 10. +Use of :locked is deprecated at - line 11. +Use of :locked is deprecated at - line 13. ######## # toke.c use warnings "syntax"; diff --git a/t/op/attrs.t b/t/op/attrs.t index a27b61e5..bf1ed84 100644 --- a/t/op/attrs.t +++ b/t/op/attrs.t @@ -10,7 +10,7 @@ BEGIN { require './test.pl'; } -plan 90; +plan 83; $SIG{__WARN__} = sub { die @_ }; @@ -19,13 +19,7 @@ sub eval_ok ($;$) { is( $@, '', @_); } -eval_ok 'sub t1 ($) : locked { $_[0]++ }'; -eval_ok 'sub t2 : locked { $_[0]++ }'; -eval_ok 'sub t3 ($) : locked ;'; -eval_ok 'sub t4 : locked ;'; -our $anon1; eval_ok '$anon1 = sub ($) : locked:method { $_[0]++ }'; -our $anon2; eval_ok '$anon2 = sub : locked : method { $_[0]++ }'; -our $anon3; eval_ok '$anon3 = sub : method { $_[0]->[1] }'; +our $anon1; eval_ok '$anon1 = sub : method { $_[0]++ }'; eval 'sub e1 ($) : plugh ;'; like $@, qr/^Invalid CODE attributes?: ["']?plugh["']? at/; @@ -97,20 +91,16 @@ sub X::foo { 1 } eval 'package Z; sub Y::bar : foo'; like $@, qr/^X at /; -eval 'package Z; sub Y::baz : locked {}'; -my @attrs = eval 'attributes::get \&Y::baz'; -is "@attrs", "locked"; - @attrs = eval 'attributes::get $anon1'; -is "@attrs", "locked method"; +is "@attrs", "method"; sub Z::DESTROY { } sub Z::FETCH_CODE_ATTRIBUTES { return 'Z' } -my $thunk = eval 'bless +sub : method locked { 1 }, "Z"'; +my $thunk = eval 'bless +sub : method { 1 }, "Z"'; is ref($thunk), "Z"; @attrs = eval 'attributes::get $thunk'; -is "@attrs", "locked method Z"; +is "@attrs", "method Z"; # Test attributes on predeclared subroutines: eval 'package A; sub PS : lvalue'; diff --git a/toke.c b/toke.c index 8f5795a..ca18af1 100644 --- a/toke.c +++ b/toke.c @@ -4395,7 +4395,7 @@ Perl_yylex(pTHX) } else if (!PL_in_my && len == 6 && strnEQ(SvPVX(sv), "locked", len)) { sv_free(sv); - CvLOCKED_on(PL_compcv); + deprecate(":locked"); } else if (!PL_in_my && len == 6 && strnEQ(SvPVX(sv), "method", len)) { sv_free(sv);