diff options
author | Father Chrysostomos <sprout@cpan.org> | 2014-10-02 12:44:19 -0700 |
---|---|---|
committer | Father Chrysostomos <sprout@cpan.org> | 2014-10-02 14:40:21 -0700 |
commit | c997e36218768fb357b1f3d160131f259311e3a3 (patch) | |
tree | 75b702930bf19281553b8ddac1eaea9268cdc054 /scope.c | |
parent | fda8e777fa2df245de209839b8b21252b2f12c47 (diff) | |
download | perl-c997e36218768fb357b1f3d160131f259311e3a3.tar.gz |
Make list assignment respect foreach aliasing
See ff2a62e0c8 for the explanation. The bug fix in that commit did
not apply to foreach’s aliasing.
In short, ($a,$b)=($c,$d) needs to account for whether two of those
variable names could be referring to the same variable.
This commit causes the test suite to exercise a code path in scope.c
added by ff2a62e0c8, which turned out to be buggy. (I forgot to test
it at the time.)
Diffstat (limited to 'scope.c')
-rw-r--r-- | scope.c | 12 |
1 files changed, 12 insertions, 0 deletions
@@ -701,6 +701,16 @@ Perl_save_alloc(pTHX_ I32 size, I32 pad) return start; } +void +Perl_save_aliased_sv(pTHX_ GV *gv) +{ + dSS_ADD; + PERL_ARGS_ASSERT_SAVE_ALIASED_SV; + SS_ADD_PTR(gp_ref(GvGP(gv))); + SS_ADD_UV(SAVEt_GP_ALIASED_SV | cBOOL(GvALIASED_SV(gv)) << 8); + SS_ADD_END(2); +} + #define ARG0_SV MUTABLE_SV(arg0.any_ptr) @@ -1231,8 +1241,10 @@ Perl_leave_scope(pTHX_ I32 base) GP * const gp = (GP *)ARG0_PTR; if (gp->gp_refcnt == 1) { GV * const gv = (GV *)sv_2mortal(newSV_type(SVt_PVGV)); + isGV_with_GP_on(gv); GvGP_set(gv,gp); gp_free(gv); + isGV_with_GP_off(gv); } else { gp->gp_refcnt--; |