? 0 : Perl_was_lvalue_sub(aTHX); \
PUSHSUB_BASE(cx) \
cx->blk_u16 = PL_op->op_private & \
- (phlags|OPpENTERSUB_DEREF); \
+ (phlags|OPpDEREF); \
}
/* variant for use by OP_DBSTATE, where op_private holds hint bits */
o->op_private &= ~1;
}
else if (type == OP_RV2SV || type == OP_RV2AV || type == OP_RV2HV){
- o->op_private |= OPpENTERSUB_DEREF;
+ o->op_private |= (type == OP_RV2AV ? OPpDEREF_AV
+ : type == OP_RV2HV ? OPpDEREF_HV
+ : OPpDEREF_SV);
o->op_flags |= OPf_MOD;
}
#define OPpENTERSUB_DB 16 /* Debug subroutine. */
#define OPpENTERSUB_HASTARG 4 /* Called from OP tree. */
#define OPpENTERSUB_INARGS 1 /* Lval used as arg to a sub. */
-#define OPpENTERSUB_DEREF 32 /* Lval call that autovivifies. */
+/* used by OPpDEREF (32|64) */
/* used by HINT_STRICT_SUBS 2 */
/* Mask for OP_ENTERSUB flags, the absence of which must be propagated
in dynamic context */
EXTEND(newsp,1);
*++newsp = &PL_sv_undef;
}
- if (CxLVAL(cx) & OPpENTERSUB_DEREF) {
+ if (CxLVAL(cx) & OPpDEREF) {
SvGETMAGIC(TOPs);
if (!SvOK(TOPs)) {
- U8 deref_type;
- if (cx->blk_sub.retop->op_type == OP_RV2SV)
- deref_type = OPpDEREF_SV;
- else if (cx->blk_sub.retop->op_type == OP_RV2AV)
- deref_type = OPpDEREF_AV;
- else {
- assert(cx->blk_sub.retop->op_type == OP_RV2HV);
- deref_type = OPpDEREF_HV;
- }
- TOPs = vivify_ref(TOPs, deref_type);
+ TOPs = vivify_ref(TOPs, CxLVAL(cx) & OPpDEREF);
}
}
}
else if (gimme == G_ARRAY) {
- assert (!(CxLVAL(cx) & OPpENTERSUB_DEREF));
+ assert (!(CxLVAL(cx) & OPpDEREF));
if (ref || !CxLVAL(cx))
while (++MARK <= SP)
*++newsp =
@INC = '../lib';
require './test.pl';
}
-plan tests=>179;
+plan tests=>181;
sub a : lvalue { my $a = 34; ${\(bless \$a)} } # Return a temporary
sub b : lvalue { ${\shift} }
undef $_;
%{&$sub()} = (4,5);
is join('-',%$_), '4-5', '%{func()} autovivification'.$suffix;
+ undef $_;
+ ${ (), &$sub()} = 4;
+ is $$_, 4, '${ (), func()} autovivification' .$suffix;
}
continue { $suffix = ' (explicit return)' }