diff options
author | Joshua ben Jore <jjore@cpan.org> | 2006-02-28 19:14:14 -0600 |
---|---|---|
committer | Rafael Garcia-Suarez <rgarciasuarez@gmail.com> | 2006-03-01 09:08:46 +0000 |
commit | 3ee1325fce9723c5c1ae0ef2ad7307ce32571c1b (patch) | |
tree | edc563eaf762c52f3bda0bef81f49f638b17b7b7 | |
parent | 1d49bf1b4cd8e1b3baa93d02705fe7df545e316f (diff) | |
download | perl-3ee1325fce9723c5c1ae0ef2ad7307ce32571c1b.tar.gz |
Re: Patch lint for grep { /.../ } and grep /.../,
From: "Joshua ben Jore" <twists@gmail.com>
Message-ID: <dc5c751d0602282314o19c54a3av92d1a3addbc895fb@mail.gmail.com>
p4raw-id: //depot/perl@27353
-rw-r--r-- | ext/B/B/Lint.pm | 9 | ||||
-rw-r--r-- | ext/B/t/lint.t | 6 |
2 files changed, 12 insertions, 3 deletions
diff --git a/ext/B/B/Lint.pm b/ext/B/B/Lint.pm index 58015b94bd..05110bfb8a 100644 --- a/ext/B/B/Lint.pm +++ b/ext/B/B/Lint.pm @@ -1,6 +1,6 @@ package B::Lint; -our $VERSION = '1.04'; +our $VERSION = '1.05'; =head1 NAME @@ -280,7 +280,12 @@ sub B::UNOP::lint { 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 $_'); } } diff --git a/ext/B/t/lint.t b/ext/B/t/lint.t index d5ee215464..01bee1b003 100644 --- a/ext/B/t/lint.t +++ b/ext/B/t/lint.t @@ -16,7 +16,7 @@ BEGIN { 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 @@ runlint 'implicit-read', '/foo/', <<'RESULT'; 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 |