diff options
author | David Mitchell <davem@iabyn.com> | 2017-12-04 11:50:53 +0000 |
---|---|---|
committer | David Mitchell <davem@iabyn.com> | 2017-12-04 12:36:25 +0000 |
commit | bcc30fd0276e8f6d4ac27d6f4c719b70a266b1fc (patch) | |
tree | b1c021234c186d26b557128c4f1dc701615fdb46 /lib/overload.t | |
parent | 56e48c10762ae388167c2f2449eea8553b396093 (diff) | |
download | perl-bcc30fd0276e8f6d4ac27d6f4c719b70a266b1fc.tar.gz |
multiconcat: don't fold adjacent constants
RT #132385
In something like
$overloaded . "a" . "b"
perl used to do
$overloaded->concat("a")->concat("b")
but since the introduction of OP_MULTICONCAT, started doing:
$overloaded->concat("ab")
This commit restores the old behaviour, by keeping every second adjacent
OP_CONST as an arg rather than optimising it away and adding its contents
to the constant string in the aux struct.
But note that
$overloaded .= "a" . "b"
originally, and still, constant folds.
Diffstat (limited to 'lib/overload.t')
-rw-r--r-- | lib/overload.t | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/lib/overload.t b/lib/overload.t index 75a7aa2b32..2afa6cf437 100644 --- a/lib/overload.t +++ b/lib/overload.t @@ -48,7 +48,7 @@ package main; $| = 1; BEGIN { require './test.pl'; require './charset_tools.pl' } -plan tests => 5332; +plan tests => 5338; use Scalar::Util qw(tainted); @@ -2891,7 +2891,7 @@ package Concat { my ($r, $R); - # like c, but with $is_ref set to 1 + # like cc, but with $is_ref set to 1 sub c { my ($expr, $expect, $exp_id) = @_; cc($expr, $expect, 1, $exp_id); @@ -2994,6 +2994,13 @@ package Concat { cc '$r.=sprintf("%s%s%s",$a,$B,$c)', 'raBc', 0, '("",[B],u,)'; cc '$R.=sprintf("%s%s%s",$a,$B,$c)', 'RaBc', 1, '("",[B],u,)(.=,[R],aBc,u)' .'("",[RaBc],u,)'; + + # multiple constants should individually overload (RT #132385) + + c '$r=$A."b"."c"', 'Abc', '(.,[A],b,)(.=,[Ab],c,u)("",[Abc],u,)'; + + # ... except for this + c '$R.="a"."b"', 'Rab', '(.=,[R],ab,u)("",[Rab],u,)'; } # RT #132385 |