From 42e73ed04a5c29db353284da1f6b2edbeb5da4fa Mon Sep 17 00:00:00 2001 From: Rick Delaney Date: Thu, 3 Aug 2006 17:48:07 -0400 Subject: [PATCH] Re: [perl #39882] inconsistent list slice behaviour Message-ID: <20060804014807.GW21381@localhost.localdomain> p4raw-id: //depot/perl@28657 --- pp.c | 2 +- t/op/list.t | 16 +++++++++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/pp.c b/pp.c index df16635..d90545e 100644 --- a/pp.c +++ b/pp.c @@ -4074,7 +4074,7 @@ PP(pp_lslice) SV ** const firstlelem = PL_stack_base + POPMARK + 1; register SV ** const firstrelem = lastlelem + 1; const I32 arybase = CopARYBASE_get(PL_curcop); - I32 is_something_there = PL_op->op_flags & OPf_MOD; + I32 is_something_there = FALSE; register const I32 max = lastrelem - lastlelem; register SV **lelem; diff --git a/t/op/list.t b/t/op/list.t index 0b3416a..a8fdc18 100755 --- a/t/op/list.t +++ b/t/op/list.t @@ -6,7 +6,7 @@ BEGIN { } require "test.pl"; -plan( tests => 52 ); +plan( tests => 57 ); @foo = (1, 2, 3, 4); cmp_ok($foo[0], '==', 1, 'first elem'); @@ -147,3 +147,17 @@ cmp_ok(join('',(1,2),3,(4,5)),'eq','12345','list (..).(..)'); my $size = scalar(()[1..1]); cmp_ok($size,'==','0','size nil'); } + +{ + # perl #39882 + sub test_zero_args { + my $test_name = shift; + is(scalar(@_), 0, $test_name); + } + test_zero_args("simple list slice", (10,11)[2,3]); + test_zero_args("grepped list slice", grep(1, (10,11)[2,3])); + test_zero_args("sorted list slice", sort((10,11)[2,3])); + test_zero_args("assigned list slice", my @tmp = (10,11)[2,3]); + test_zero_args("do-returned list slice", do { (10,11)[2,3]; }); +} + -- 2.7.4