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.
| ((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);
return $ok;
}
-print "1..30\n";
+print "1..31\n";
($a, $b, $c) = qw(foo bar);
$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');