Change 27353 by [EMAIL PROTECTED] on 2006/03/01 09:08:46

        Subject: Re: Patch lint for grep { /.../ } and grep /.../,
        From: "Joshua ben Jore" <[EMAIL PROTECTED]>
        Date: Wed, 1 Mar 2006 01:14:14 -0600
        Message-ID: <[EMAIL PROTECTED]>

Affected files ...

... //depot/perl/ext/B/B/Lint.pm#21 edit
... //depot/perl/ext/B/t/lint.t#15 edit

Differences ...

==== //depot/perl/ext/B/B/Lint.pm#21 (text) ====
Index: perl/ext/B/B/Lint.pm
--- perl/ext/B/B/Lint.pm#20~26421~      2005-12-20 06:54:10.000000000 -0800
+++ perl/ext/B/B/Lint.pm        2006-03-01 01:08:46.000000000 -0800
@@ -1,6 +1,6 @@
 package B::Lint;
 
-our $VERSION = '1.04';
+our $VERSION = '1.05';
 
 =head1 NAME
 
@@ -280,7 +280,12 @@
 sub B::PMOP::lint {
     my $op = shift;
     if ($check{implicit_read}) {
-       if ($op->name eq "match" && !($op->flags & OPf_STACKED)) {
+       if ($op->name eq "match"
+               and not ( $op->flags & OPf_STACKED
+                   or join( " ",
+                       map $_->name,
+                       @{B::parents()} )
+               =~ /^(?:leave )?(?:null )*grep/ ) ) {
            warning('Implicit match on $_');
        }
     }

==== //depot/perl/ext/B/t/lint.t#15 (text) ====
Index: perl/ext/B/t/lint.t
--- perl/ext/B/t/lint.t#14~26501~       2005-12-27 06:10:20.000000000 -0800
+++ perl/ext/B/t/lint.t 2006-03-01 01:08:46.000000000 -0800
@@ -16,7 +16,7 @@
     require 'test.pl';
 }
 
-plan tests => 16; # adjust also number of skipped tests !
+plan tests => 18; # adjust also number of skipped tests !
 
 # Runs a separate perl interpreter with the appropriate lint options
 # turned on
@@ -43,6 +43,10 @@
 Implicit match on $_ at -e line 1
 RESULT
 
+runlint 'implicit-read', 'grep /foo/, ()', '';
+
+runlint 'implicit-read', 'grep { /foo/ } ()', '';
+
 runlint 'implicit-write', 's/foo/bar/', <<'RESULT';
 Implicit substitution on $_ at -e line 1
 RESULT
End of Patch.

Reply via email to