diff options
author | Father Chrysostomos <sprout@cpan.org> | 2011-06-21 23:02:25 -0700 |
---|---|---|
committer | Father Chrysostomos <sprout@cpan.org> | 2011-06-22 08:21:14 -0700 |
commit | bb3abb059a118f508179df292a0a6e562767107f (patch) | |
tree | 4f392856cc80bca46ff02d854b34ae6376ddd33f /ext | |
parent | eddd77ceed2006321182714bd36a37ee8620dbde (diff) | |
download | perl-bb3abb059a118f508179df292a0a6e562767107f.tar.gz |
attributes.pm: warn & don’t apply :lvalue to defined subs
This is something that ‘sub foo :lvalue;’ declarations do. This brings
attributes.pm in line with them.
See commits fff96ff and 885ef6f, ticket #68758, and
<364E1F98-FDCC-49A7-BADB-BD844626B8AE@cpan.org>.
Diffstat (limited to 'ext')
-rw-r--r-- | ext/attributes/attributes.pm | 9 | ||||
-rw-r--r-- | ext/attributes/attributes.xs | 4 |
2 files changed, 13 insertions, 0 deletions
diff --git a/ext/attributes/attributes.pm b/ext/attributes/attributes.pm index f79db0fd8c..a7c6716f57 100644 --- a/ext/attributes/attributes.pm +++ b/ext/attributes/attributes.pm @@ -34,6 +34,15 @@ sub _modify_attrs_and_deprecate { require warnings; warnings::warnif('deprecated', "Attribute \"$1\" is deprecated"); 0; + } : $svtype eq 'CODE' && /^-?lvalue\z/ ? do { + require warnings; + warnings::warnif( + 'misc', + "lvalue attribute " + . (/^-/ ? "cannot be removed" : "ignored") + . " after the subroutine has been defined" + ); + 0; } : 1 } _modify_attrs(@_); } diff --git a/ext/attributes/attributes.xs b/ext/attributes/attributes.xs index 20dc33d187..24f5f6185e 100644 --- a/ext/attributes/attributes.xs +++ b/ext/attributes/attributes.xs @@ -48,6 +48,10 @@ modify_SV_attributes(pTHX_ SV *sv, SV **retlist, SV **attrlist, int numattrs) switch (name[3]) { case 'l': if (memEQ(name, "lvalue", 6)) { + if (!CvISXSUB(MUTABLE_CV(sv)) + && CvROOT(MUTABLE_CV(sv)) + && !CvLVALUE(MUTABLE_CV(sv)) != negated) + break; if (negated) CvFLAGS(MUTABLE_CV(sv)) &= ~CVf_LVALUE; else |