In perl.git, the branch blead has been updated <http://perl5.git.perl.org/perl.git/commitdiff/ada289e74406815f75328d011e5521339169abe7?hp=aab1202a8d4b691b16384fb41d2e2a06abf664e2>
- Log ----------------------------------------------------------------- commit ada289e74406815f75328d011e5521339169abe7 Author: Father Chrysostomos <[email protected]> Date: Wed Mar 25 22:55:20 2015 -0700 [perl #124160] Disable targlex for state var init The targlex optimisation optimises away an assignment to a lexical variable, having the operator on the rhs write directly to the lexi- cal itself. This optimisation has a bug in it (#101640) that causes $lex = "a $b c" to stringify the result, instead of allowing con- cat overloding to return something other than a string. I extended the optimisation to occur with state variable initialization, in v5.21.5-366-ga1b22ab, not realising it would make an existing bug occur more often. For now, just disable the new optimisation. ----------------------------------------------------------------------- Summary of changes: op.c | 3 +++ t/opbasic/concat.t | 8 +++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/op.c b/op.c index a07eb05..89bf436 100644 --- a/op.c +++ b/op.c @@ -10476,7 +10476,10 @@ Perl_ck_sassign(pTHX_ OP *o) | ((kkid->op_private & ~OPpLVAL_INTRO) << 8)); OP *const first = newOP(OP_NULL, 0); OP *const nullop = + newCONDOP(0, first, o, other); + /* XXX targlex disabled for now; see ticket #124160 newCONDOP(0, first, S_maybe_targlex(aTHX_ o), other); + */ OP *const condop = first->op_next; OpTYPE_set(condop, OP_ONCE); diff --git a/t/opbasic/concat.t b/t/opbasic/concat.t index f020992..9c4cbe2 100644 --- a/t/opbasic/concat.t +++ b/t/opbasic/concat.t @@ -22,7 +22,7 @@ sub ok { return $ok; } -print "1..30\n"; +print "1..31\n"; ($a, $b, $c) = qw(foo bar); @@ -163,3 +163,9 @@ sub beq { use bytes; $_[0] eq $_[1]; } $x .= "-append-"; ok($x eq "ab-append-", "Appending to something initialized using constant folding"); } + +# [perl #124160] +package o { use overload "." => sub { $_[0] }, fallback => 1 } +$o = bless [], "o"; +ok(ref(CORE::state $y = "a $o b") eq 'o', + 'state $y = "foo $bar baz" does not stringify; only concats'); -- Perl5 Master Repository
