diff options
author | Father Chrysostomos <sprout@cpan.org> | 2014-10-02 22:38:27 -0700 |
---|---|---|
committer | Father Chrysostomos <sprout@cpan.org> | 2014-10-11 00:10:15 -0700 |
commit | d39c26a657753cddffc8cb3dbd2aaa929b2c78fe (patch) | |
tree | e3061d7ad6cb247565e7ce16a74db2eddc5a07e7 /pp_ctl.c | |
parent | 5a36b2c090849e18b86c1759887c5bcebd598113 (diff) | |
download | perl-d39c26a657753cddffc8cb3dbd2aaa929b2c78fe.tar.gz |
foreach \$var
Some passing tests are still marked to-do. We need more tests still.
Diffstat (limited to 'pp_ctl.c')
-rw-r--r-- | pp_ctl.c | 12 |
1 files changed, 11 insertions, 1 deletions
@@ -2112,7 +2112,7 @@ PP(pp_enteriter) itervar = &PAD_SVl(PL_op->op_targ); #endif } - else { /* symbol table variable */ + else if (LIKELY(isGV(TOPs))) { /* symbol table variable */ GV * const gv = MUTABLE_GV(POPs); SV** svp = &GvSV(gv); save_pushptrptr(gv, SvREFCNT_inc(*svp), SAVEt_GVSV); @@ -2120,6 +2120,14 @@ PP(pp_enteriter) itervar = (void *)gv; save_aliased_sv(gv); } + else { + SV * const sv = POPs; + assert(SvTYPE(sv) == SVt_PVMG); + assert(SvMAGIC(sv)); + assert(SvMAGIC(sv)->mg_type == PERL_MAGIC_lvref); + itervar = (void *)sv; + cxtype |= CXp_FOR_LVREF; + } if (PL_op->op_private & OPpITER_DEF) cxtype |= CXp_FOR_DEF; @@ -2133,6 +2141,8 @@ PP(pp_enteriter) if (SvTYPE(maybe_ary) != SVt_PVAV) { dPOPss; SV * const right = maybe_ary; + if (UNLIKELY(cxtype & CXp_FOR_LVREF)) + DIE(aTHX_ "Assigned value is not a reference"); SvGETMAGIC(sv); SvGETMAGIC(right); if (RANGE_IS_NUMERIC(sv,right)) { |