If you return void from a filter subroutine, the caller's status is
authorNicholas Clark <nick@ccl4.org>
Sat, 15 Apr 2006 16:43:22 +0000 (16:43 +0000)
committerNicholas Clark <nick@ccl4.org>
Sat, 15 Apr 2006 16:43:22 +0000 (16:43 +0000)
used. If not, your last statement is the return value, and if it keeps
being +ve you'll never hit EOF.
The probably should be a sanity check for this in toke.c, but I'm not
sure how.

p4raw-id: //depot/perl@27814

t/op/incfilter.t

index 4dbf7e9..2ca4704 100644 (file)
@@ -56,11 +56,11 @@ do [sub {
 
 open $fh, "<", \'fail("File handles and filters work from \@INC");';
 
-do [$fh, sub {s/fail/pass/}] or die;
+do [$fh, sub {s/fail/pass/; return;}] or die;
 
 open $fh, "<", \'fail("File handles and filters with state work from \@INC");';
 
-do [$fh, sub {s/$_[1]/pass/}, 'fail'] or die;
+do [$fh, sub {s/$_[1]/pass/; return;}, 'fail'] or die;
 
 print "# 2 tests with pipes from subprocesses.\n";
 
@@ -70,7 +70,7 @@ do $fh or die;
 
 open $fh, 'echo fail|' or die $!;
 
-do [$fh, sub {s/$_[1]/pass/}, 'fail'] or die;
+do [$fh, sub {s/$_[1]/pass/; return;}, 'fail'] or die;
 
 sub rot13_filter {
     filter_add(sub {
@@ -92,7 +92,7 @@ ORTVA {ebg13_svygre};
 pass("This will rot13'ed twice");
 EOC
 
-do [$fh, sub {tr/A-Za-z/N-ZA-Mn-za-m/;}] or die;
+do [$fh, sub {tr/A-Za-z/N-ZA-Mn-za-m/; return;}] or die;
 
 my $count = 32;
 sub prepend_rot13_filter {
@@ -119,4 +119,4 @@ ORTVA {cercraq_ebg13_svygre};
 pass("This will rot13'ed twice");
 EOC
 
-do [$fh, sub {tr/A-Za-z/N-ZA-Mn-za-m/;}] or die;
+do [$fh, sub {tr/A-Za-z/N-ZA-Mn-za-m/; return;}] or die;