In perl.git, the branch blead has been updated

<http://perl5.git.perl.org/perl.git/commitdiff/f6435df36c4167f97876032948ee21a446b75f27?hp=13290fcd82823e130109fca5199c99fb886e29eb>

- Log -----------------------------------------------------------------
commit f6435df36c4167f97876032948ee21a446b75f27
Author: Gerard Goossen <ger...@ggoossen.net>
Date:   Tue Dec 8 12:42:58 2009 +0100

    proper error on "grep $x (1,2,3)". Solves [perl #37314]
-----------------------------------------------------------------------

Summary of changes:
 op.c        |    8 ++++----
 t/op/grep.t |    9 ++++++++-
 2 files changed, 12 insertions(+), 5 deletions(-)

diff --git a/op.c b/op.c
index 5cbf917..bc8403a 100644
--- a/op.c
+++ b/op.c
@@ -7210,10 +7210,10 @@ Perl_ck_grep(pTHX_ OP *o)
     if (o->op_flags & OPf_STACKED) {
        OP* k;
        o = ck_sort(o);
-        kid = cLISTOPo->op_first->op_sibling;
-       if (!cUNOPx(kid)->op_next)
-           Perl_croak(aTHX_ "panic: ck_grep");
-       for (k = cUNOPx(kid)->op_first; k; k = k->op_next) {
+        kid = cUNOPx(cLISTOPo->op_first->op_sibling)->op_first;
+       if (kid->op_type != OP_SCOPE && kid->op_type != OP_LEAVE)
+           return no_fh_allowed(o);
+       for (k = kid; k; k = k->op_next) {
            kid = k;
        }
        NewOp(1101, gwop, 1, LOGOP);
diff --git a/t/op/grep.t b/t/op/grep.t
index d7fe515..456b6c5 100644
--- a/t/op/grep.t
+++ b/t/op/grep.t
@@ -10,7 +10,7 @@ BEGIN {
 }
 
 require "test.pl";
-plan( tests => 60 );
+plan( tests => 61 );
 
 {
     my @lol = ([qw(a b c)], [], [qw(1 2 3)]);
@@ -207,3 +207,10 @@ plan( tests => 60 );
     my @empty = map { while (1) {} } ();
     cmp_ok("@empty", 'eq', '', 'staying alive');
 }
+
+{
+    my $x;
+    eval 'grep $x (1,2,3);';
+    like($@, qr/Missing comma after first argument to grep function/,
+         "proper error on variable as block. [perl #37314]");
+}

--
Perl5 Master Repository

Reply via email to