Re: [perl #30688] Empty slice arg with ($;$) prototype
authorRick Delaney <rick@consumercontact.com>
Tue, 20 Jul 2004 16:53:54 +0000 (12:53 -0400)
committerRafael Garcia-Suarez <rgarciasuarez@gmail.com>
Wed, 21 Jul 2004 08:47:14 +0000 (08:47 +0000)
Message-ID: <20040720205353.GA970@biff.bort.ca>

p4raw-id: //depot/perl@23145

pp.c
t/op/list.t

diff --git a/pp.c b/pp.c
index 51cd5d4..2b38805 100644 (file)
--- a/pp.c
+++ b/pp.c
@@ -3749,7 +3749,7 @@ PP(pp_aslice)
     }
     if (GIMME != G_ARRAY) {
        MARK = ORIGMARK;
-       *++MARK = *SP;
+       *++MARK = SP > ORIGMARK ? *SP : &PL_sv_undef;
        SP = MARK;
     }
     RETURN;
@@ -3949,7 +3949,7 @@ PP(pp_hslice)
     }
     if (GIMME != G_ARRAY) {
        MARK = ORIGMARK;
-       *++MARK = *SP;
+       *++MARK = SP > ORIGMARK ? *SP : &PL_sv_undef;
        SP = MARK;
     }
     RETURN;
index 4d7a2d5..89ccf02 100755 (executable)
@@ -1,6 +1,6 @@
 #!./perl
 
-print "1..28\n";
+print "1..30\n";
 
 @foo = (1, 2, 3, 4);
 if ($foo[0] == 1 && $foo[3] == 4) {print "ok 1\n";} else {print "not ok 1\n";}
@@ -86,4 +86,13 @@ for ($x = 0; $x < 3; $x++) {
     my @c = (0, undef, undef, 3)[1, 2];
     print "not " unless @b == @c and @c == 2;
     print "ok 28\n";
+
+    @b = (29, scalar @c[()]);
+    print "not " if join(':',@b) ne '29:';
+    print "ok 29\n";
+
+    my %h = (a => 1);
+    @b = (30, scalar @h{()});
+    print "not " if join(':',@b) ne '30:';
+    print "ok 30\n";
 }