develooper Front page | perl.perl5.porters | Postings from April 2006

expr foreach (...) isn't a B::Lint warning anymore

Thread Next
From:
Joshua ben Jore
Date:
April 3, 2006 23:27
Subject:
expr foreach (...) isn't a B::Lint warning anymore
Message ID:
dc5c751d0604032327l7c9027d1t212671bf987f98d9@mail.gmail.com
Right now, both of C<for ( ... ) { ... }> and C<... for ...;> produce
the warning "Implicit use of $_ in foreach". I think this is wrong
since it prevents ever using the statement modifier version of
foreach.

Josh

diff -ur bleadperl/ext/B/t/lint.t myblead/ext/B/t/lint.t
--- bleadperl/ext/B/t/lint.t    2006-04-04 01:23:29.000000000 -0500
+++ myblead/ext/B/t/lint.t      2006-04-04 01:19:54.000000000 -0500
@@ -16,7 +16,7 @@
     require 'test.pl';
 }

-plan tests => 18; # adjust also number of skipped tests !
+plan tests => 19; # adjust also number of skipped tests !

 # Runs a separate perl interpreter with the appropriate lint options
 # turned on
@@ -66,10 +66,13 @@
     skip("Doesn't work with threaded perls",11)
        if $Config{useithreads} || ($] < 5.009 && $Config{use5005threads});

-    runlint 'implicit-read', '1 for @ARGV', <<'RESULT', 'implicit-read in fore
ch';
+    runlint 'implicit-read', 'for ( @ARGV ) { 1 }', <<'RESULT', 'implicit-read
in foreach';
 Implicit use of $_ in foreach at -e line 1
 RESULT

+    runlint 'implicit-read', '1 for @ARGV', <<'RESULT', 'implicit-read in fore
ch';
+RESULT
+
     runlint 'dollar-underscore', '$_ = 1', <<'RESULT';
 Use of $_ at -e line 1
 RESULT

Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About