In perl.git, the branch blead has been updated <http://perl5.git.perl.org/perl.git/commitdiff/689d8423b7692a628b08f883e8c57c3f4db2f96a?hp=0cb3abac7ce8e46384e09eaa26fafa0af738ad61>
- Log ----------------------------------------------------------------- commit 689d8423b7692a628b08f883e8c57c3f4db2f96a Author: Father Chrysostomos <[email protected]> Date: Mon Oct 13 08:27:02 2014 -0700 [perl #122965] aelemfast in list assignment I accidentally broke ($_[0],$_[1])=($_[1],$_[0]) in be9de18, which was only supposed to be a refactoring. Since it now happens later in the compilation phase when optimisations like aelemfast have happened, the search for common vars needs to take aelemfast into account. ----------------------------------------------------------------------- Summary of changes: op.c | 3 ++- opcode.h | 2 +- regen/opcodes | 2 +- t/op/array.t | 8 +++++++- 4 files changed, 11 insertions(+), 4 deletions(-) diff --git a/op.c b/op.c index 7b8c176..5259338 100644 --- a/op.c +++ b/op.c @@ -5917,7 +5917,8 @@ S_aassign_common_vars(pTHX_ OP* o) OP *curop; for (curop = cUNOPo->op_first; curop; curop = OP_SIBLING(curop)) { if (PL_opargs[curop->op_type] & OA_DANGEROUS) { - if (curop->op_type == OP_GV || curop->op_type == OP_GVSV) { + if (curop->op_type == OP_GV || curop->op_type == OP_GVSV + || curop->op_type == OP_AELEMFAST) { GV *gv = cGVOPx_gv(curop); if (gv == PL_defgv || (int)GvASSIGN_GENERATION(gv) == PL_generation) diff --git a/opcode.h b/opcode.h index f555e91..9773408 100644 --- a/opcode.h +++ b/opcode.h @@ -1868,7 +1868,7 @@ EXTCONST U32 PL_opargs[] = { 0x00009b8e, /* lc */ 0x00009b8e, /* quotemeta */ 0x00000148, /* rv2av */ - 0x00013604, /* aelemfast */ + 0x00013644, /* aelemfast */ 0x00013040, /* aelemfast_lex */ 0x00013204, /* aelem */ 0x00023401, /* aslice */ diff --git a/regen/opcodes b/regen/opcodes index e0d3c9e..07910ed 100644 --- a/regen/opcodes +++ b/regen/opcodes @@ -213,7 +213,7 @@ quotemeta quotemeta ck_fun fstu% S? # Arrays. rv2av array dereference ck_rvconst dt1 -aelemfast constant array element ck_null s$ A S +aelemfast constant array element ck_null ds$ A S aelemfast_lex constant lexical array element ck_null d0 A S aelem array element ck_null s2 A S aslice array slice ck_null m@ A L diff --git a/t/op/array.t b/t/op/array.t index 54ef3f2..30a1e1d 100644 --- a/t/op/array.t +++ b/t/op/array.t @@ -6,7 +6,7 @@ BEGIN { require './test.pl'; } -plan (170); +plan (171); # # @foo, @bar, and @ary are also used from tie-stdarray after tie-ing them @@ -540,4 +540,10 @@ pass "no assertion failure after assigning ref to arylen when ary is gone"; is($aelem[ 256], 256, 'pkg 256'); } +# Test aelemfast in list assignment +@ary = ('a','b'); +($ary[0],$ary[1]) = ($ary[1],$ary[0]); +is "@ary", 'b a', + 'aelemfast with the same array on both sides of list assignment'; + "We're included by lib/Tie/Array/std.t so we need to return something true"; -- Perl5 Master Repository
