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
+=item lvalue attribute %s already-defined subroutine
-(W misc) The lvalue attribute on a Perl subroutine cannot be turned off
-once the subroutine is defined.
+(W misc) Although L<attributes.pm|attributes> allows this, turning the lvalue
+attribute on or off on a Perl subroutine that is already defined
+does not always work properly. It may or may not do what you
+want, depending on what code is inside the subroutine, with exact
+details subject to change between Perl versions. Only do this
+if you really know what you are doing.
=item lvalue attribute ignored after the subroutine has been defined
-(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.
+(W misc) Using the C<:lvalue> declarative syntax to make a Perl
+subroutine an lvalue subroutine after it has been defined is
+not permitted. To make the subroutine an lvalue subroutine,
+add the lvalue attribute to the definition, or put the C<sub
+foo :lvalue;> declaration before the definition.
+
+See also L<attributes.pm|attributes>.
=item Malformed integer in [] in pack
sub ent {}
sub lent :lvalue {}
my $posmsg =
- 'lvalue attribute ignored after the subroutine has been defined at '
+ 'lvalue attribute applied to already-defined subroutine at '
.'\(eval';
my $negmsg =
- 'lvalue attribute cannot be removed after the subroutine has been '
- .'defined at \(eval';
+ 'lvalue attribute removed from already-defined subroutine 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';
+ is join("",&attributes::get(\&ent)), "lvalue",':lvalue applied anyway';
$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';
+ like $w, qr/^$negmsg/, '-lvalue attr warning on def sub';
+ is join("",&attributes::get(\&lent)), "",
+ 'lvalue attribute removed anyway';
$w = '';
- eval 'use attributes __PACKAGE__, \&ent, "-lvalue"; 1' or die;
- is $w, "", 'no lvalue warning on def lvalue sub';
+ eval 'use attributes __PACKAGE__, \&lent, "-lvalue"; 1' or die;
+ is $w, "", 'no -lvalue warning on def non-lvalue sub';
no warnings 'misc';
- eval 'use attributes __PACKAGE__, \&ent, "lvalue"';
+ eval 'use attributes __PACKAGE__, \&lent, "lvalue"';
is $w, "", 'no lvalue warnings under no warnings misc';
- eval 'use attributes __PACKAGE__, \&lent, "-lvalue"';
+ eval 'use attributes __PACKAGE__, \&ent, "-lvalue"';
is $w, "", 'no -lvalue warnings under no warnings misc';
}