summaryrefslogtreecommitdiff
path: root/pp.c
diff options
context:
space:
mode:
authorFather Chrysostomos <sprout@cpan.org>2011-04-18 21:29:11 -0700
committerFather Chrysostomos <sprout@cpan.org>2011-04-18 21:29:32 -0700
commitd806590792484020987549ec4683b175c90d6263 (patch)
treea86f5ad78f320212167e68200755801e977bf194 /pp.c
parent006671a67d63718163a0f4771c9dc358db053aad (diff)
downloadperl-d806590792484020987549ec4683b175c90d6263.tar.gz
Make keys $scalar an lvalue
This does a run-time check to see whether $scalar is a hash ref, and dies if it is not. This is to keep keys \@_ consistent with keys @_. I cannot simply use OPf_MOD, since that indicates *potential* lvalue context (including subroutine args). So, instead, I take advantage of the fact that OPf_SPECIAL is always set on the LHS of an assignment (usually to indicate that local() should not erase the value).
Diffstat (limited to 'pp.c')
-rw-r--r--pp.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/pp.c b/pp.c
index 5b32daf78e..4c8827065a 100644
--- a/pp.c
+++ b/pp.c
@@ -4850,6 +4850,12 @@ PP(pp_rkeys)
PL_op_desc[PL_op->op_type] );
}
+ if (PL_op->op_flags & OPf_SPECIAL && SvTYPE(sv) == SVt_PVAV)
+ DIE(aTHX_
+ "Can't modify %s in %s",
+ PL_op_desc[PL_op->op_type], PL_op_desc[PL_op->op_next->op_type]
+ );
+
/* Delegate to correct function for op type */
PUSHs(sv);
if (PL_op->op_type == OP_RKEYS || PL_op->op_type == OP_RVALUES) {