summaryrefslogtreecommitdiff
path: root/t/opbasic
diff options
context:
space:
mode:
authorFather Chrysostomos <sprout@cpan.org>2015-03-25 22:55:20 -0700
committerFather Chrysostomos <sprout@cpan.org>2015-03-25 22:55:20 -0700
commitada289e74406815f75328d011e5521339169abe7 (patch)
treeea2518aac71cf995b66ea0019ed7d9f475b5bc35 /t/opbasic
parentaab1202a8d4b691b16384fb41d2e2a06abf664e2 (diff)
downloadperl-ada289e74406815f75328d011e5521339169abe7.tar.gz
[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.
Diffstat (limited to 't/opbasic')
-rw-r--r--t/opbasic/concat.t8
1 files changed, 7 insertions, 1 deletions
diff --git a/t/opbasic/concat.t b/t/opbasic/concat.t
index f020992ac8..9c4cbe20e2 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');