From: Vincent Pit Date: Sun, 1 Nov 2009 00:49:59 +0000 (-0500) Subject: Re: [perl #38809][PATCH] loss of stack elements with a do block inside a return X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=60aa6a1aa894dd62b8194841a6d6c80c15079dba;p=p5sagit%2Fp5-mst-13.2.git Re: [perl #38809][PATCH] loss of stack elements with a do block inside a return --- diff --git a/t/op/do.t b/t/op/do.t index e47441a..3be0d3a 100644 --- a/t/op/do.t +++ b/t/op/do.t @@ -29,7 +29,7 @@ sub ok { return $ok; } -print "1..50\n"; +print "1..54\n"; # Test do &sub and proper @_ handling. $_[0] = 0; @@ -191,6 +191,18 @@ ok($x == 4, 'if (0){} else { ...; @a } receives caller scalar context'); ok("@x" eq "24 25 26 27", 'if (0){} else { ...; @a } receives caller list context'); +# [perl #38809] +@a = (7, 8); +$x = sub { do { return do { 1; @a } }; 3 }->(); +ok(defined $x && $x == 2, 'return do { } receives caller scalar context'); +@x = sub { do { return do { 1; @a } }; 3 }->(); +ok("@x" eq "7 8", 'return do { } receives caller list context'); +@a = (7, 8, 9); +$x = sub { do { do { 1; return @a } }; 4 }->(); +ok(defined $x && $x == 3, 'do { return } receives caller scalar context'); +@x = sub { do { do { 1; return @a } }; 4 }->(); +ok("@x" eq "7 8 9", 'do { return } receives caller list context'); + END { 1 while unlink("$$.16", "$$.17", "$$.18"); }