diff options
author | David Mitchell <davem@iabyn.com> | 2017-11-28 09:08:09 +0000 |
---|---|---|
committer | David Mitchell <davem@iabyn.com> | 2017-11-28 09:23:57 +0000 |
commit | d7e75038064881b413f76de9315a5acfb21472f0 (patch) | |
tree | cab03635d72d7d1624a57406fb4192ea5b3df10d /lib/overload.t | |
parent | 04139aa0b51c7b5d9f80f77b10f85ce4c65a4cf6 (diff) | |
download | perl-d7e75038064881b413f76de9315a5acfb21472f0.tar.gz |
$overloaded .= $x: don't stringify $x
RT #132385
This is a variant of the ($ref . $overloaded) bug which was fixed with
v5.27.5-195-gb3ab0375cb.
Basically, when the overloaded concat method is called, it should pass
$x as-is, rather than as "$x". This fixes PDL-2.018
Diffstat (limited to 'lib/overload.t')
-rw-r--r-- | lib/overload.t | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/lib/overload.t b/lib/overload.t index 46b193be21..75a7aa2b32 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 => 5331; +plan tests => 5332; use Scalar::Util qw(tainted); @@ -3003,17 +3003,20 @@ package Concat { # concat($right, $left, 1) # rather than # concat($right, "$left", 1) +# There's a similar issue with +# $left .= $right +# when left is overloaded package RT132385 { use constant C => [ "constref" ]; use overload '.' => sub { - my ($r, $l, $rev) = @_; - die "expected reverse\n" unless $rev; - my $res = ref $l ? $l->[0] : "$l"; - $res .= "-" . $r->[0]; - $res; + my ($l, $r, $rev) = @_; + ($l,$r) = ($r,$l) if $rev; + $l = ref $l ? $l->[0] : "$l"; + $r = ref $r ? $r->[0] : "$r"; + "$l-$r"; } ; @@ -3033,4 +3036,7 @@ package RT132385 { ::like($r1.$r2.$o, qr/^ARRAY\(0x\w+\)ARRAY\(0x\w+\)-obj/, "RT #132385 r1.r2.o"); + + # ditto with a mutator + ::is($o .= $r1, "obj-ref1", "RT #132385 o.=r1"); } |