&& block->op_type != OP_NULL
#endif
) {
+ cv_flags_t existing_builtin_attrs = CvFLAGS(cv) & CVf_BUILTIN_ATTRS;
cv_undef(cv);
- CvFLAGS(cv) = CvFLAGS(PL_compcv);
+ CvFLAGS(cv) = CvFLAGS(PL_compcv) | existing_builtin_attrs;
if (!CvWEAKOUTSIDE(cv))
SvREFCNT_dec(CvOUTSIDE(cv));
CvOUTSIDE(cv) = CvOUTSIDE(PL_compcv);
use warnings;
-plan 91;
+plan 92;
$SIG{__WARN__} = sub { die @_ };
@attrs = eval 'attributes::get \&A::PS';
is "@attrs", "lvalue";
+# Test attributes on predeclared subroutines, after definition
+eval 'package A; sub PS : lvalue; sub PS { }';
+@attrs = eval 'attributes::get \&A::PS';
+is "@attrs", "lvalue";
+
# Test ability to modify existing sub's (or XSUB's) attributes.
eval 'package A; sub X { $_[0] } sub X : method';
@attrs = eval 'attributes::get \&A::X';
@INC = '../lib';
require './test.pl';
}
-plan tests=>70;
+plan tests=>71;
sub a : lvalue { my $a = 34; ${\(bless \$a)} } # Return a temporary
sub b : lvalue { ${\shift} }
Can't modify non-lvalue subroutine call in scalar assignment at - line 5, near "3;"
Execution of - aborted due to compilation errors.
====
+
+{
+ my $x;
+ sub lval_decl : lvalue;
+ sub lval_decl { $x }
+ lval_decl = 5;
+ is($x, 5, "subroutine declared with lvalue before definition retains lvalue. [perl #68758]");
+}