This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
overloaded <> sometimes left an extra stack arg
authorDavid Mitchell <davem@iabyn.com>
Sun, 2 Jan 2011 15:04:50 +0000 (15:04 +0000)
committerDavid Mitchell <davem@iabyn.com>
Sun, 2 Jan 2011 20:00:27 +0000 (20:00 +0000)
lib/overload.t
pp.h

index f9ba064..20d3e21 100644 (file)
@@ -48,7 +48,7 @@ package main;
 
 $| = 1;
 BEGIN { require './test.pl' }
-plan tests => 4936;
+plan tests => 4942;
 
 use Scalar::Util qw(tainted);
 
@@ -2151,6 +2151,23 @@ fresh_perl_is
     }
 }
 
+# since 5.6 overloaded <> was leaving an extra arg on the stack!
+
+{
+    package Iter1;
+    use overload '<>' => sub { 11 };
+    package main;
+    my $a = bless [], 'Iter1';
+    my $x;
+    my @a = (10, ($x = <$a>), 12);
+    is ($a[0], 10, 'Iter1: a[0]');
+    is ($a[1], 11, 'Iter1: a[1]');
+    is ($a[2], 12, 'Iter1: a[2]');
+    @a = (10, ($x .= <$a>), 12);
+    is ($a[0],   10, 'Iter1: a[0] concat');
+    is ($a[1], 1111, 'Iter1: a[1] concat');
+    is ($a[2],   12, 'Iter1: a[2] concat');
+}
 
 
 # EOF
diff --git a/pp.h b/pp.h
index debdd2d..5ba9ae2 100644 (file)
--- a/pp.h
+++ b/pp.h
@@ -446,6 +446,8 @@ Does not use C<TARG>.  See also C<XPUSHu>, C<mPUSHu> and C<PUSHu>.
                SPAGAIN;                                        \
                sp += shift;                                    \
                sv_setsv(TARG, tmpsv);                          \
+               if (opASSIGN)                                   \
+                   sp--;                                       \
                SETTARG;                                        \
                RETURN;                                         \
            }                                                   \