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(@_);
}
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
=item *
-L<XXX> has been upgraded from version 0.69 to version 0.70.
+L<attributes> has been upgraded from version 0.14 to 0.15, as part of the
+lvalue attribute warnings fix. See L</Selected Bug Fixes>, below.
=back
C<foo> is already defined) now warns about the :lvalue attribute, and does
not apply it.
+L<attributes.pm|attributes> has likewise been updated to warn and not apply
+the attribute.
+
=back
=head1 Known Problems
by that? lstat() makes sense only on filenames. (Perl did a fstat()
instead on the filehandle.)
+=item lvalue attribute cannot be removed after the subroutine has been defined
+
+(W misc) The lvalue attribute on a Perl subroutine cannot be turned off
+once the subroutine is defined.
+
=item lvalue attribute ignored after the subroutine has been defined
-(W misc) Making a subroutine an lvalue subroutine after it has been defined
-by declaring the subroutine with an lvalue attribute is not
-possible. To make the subroutine an lvalue subroutine add the
-lvalue attribute to the definition, or put the declaration before
-the definition.
+(W misc) Making a Perl subroutine an lvalue subroutine after it has been
+defined, whether by declaring the subroutine with an lvalue attribute
+or by using L<attributes.pm|attributes>, is not possible. To make the subroutine an
+lvalue subroutine, add the lvalue attribute to the definition, or put
+the declaration before the definition.
=item Malformed integer in [] in pack
::is "@go", 'jabber joo', 'list assignment to array with attrs';
}
+{
+ my $w;
+ local $SIG{__WARN__} = sub { $w = shift };
+ sub ent {}
+ sub lent :lvalue {}
+ my $posmsg =
+ 'lvalue attribute ignored after the subroutine has been defined at '
+ .'\(eval';
+ my $negmsg =
+ 'lvalue attribute cannot be removed after the subroutine has been '
+ .'defined at \(eval';
+ eval 'use attributes __PACKAGE__, \&ent, "lvalue"';
+ like $w, qr/^$posmsg/, 'lvalue attr warning on def sub';
+ is join("",&attributes::get(\&ent)), "",'lvalue attr ignored on def sub';
+ $w = '';
+ eval 'use attributes __PACKAGE__, \&lent, "lvalue"; 1' or die;
+ is $w, "", 'no lvalue warning on def lvalue sub';
+ eval 'use attributes __PACKAGE__, \&lent, "-lvalue"';
+ like $w, qr/^$negmsg/, 'lvalue attr warning on def sub';
+ is join("",&attributes::get(\&lent)), "lvalue",
+ '-lvalue ignored on def sub';
+ $w = '';
+ eval 'use attributes __PACKAGE__, \&ent, "-lvalue"; 1' or die;
+ is $w, "", 'no lvalue warning on def lvalue sub';
+ no warnings 'misc';
+ eval 'use attributes __PACKAGE__, \&ent, "lvalue"';
+ is $w, "", 'no lvalue warnings under no warnings misc';
+ eval 'use attributes __PACKAGE__, \&lent, "-lvalue"';
+ is $w, "", 'no -lvalue warnings under no warnings misc';
+}
+
done_testing();