Hello all,

I am not even 100% sure these are bugs. I assume I should be able to do this, but I dont know for sure.

These two test groups (taken from t/builtins/io/io_in_for_loop.t) below will fail with the error:

        pugs: tempfile: hGetLine: illegal operation (handle is closed)

it seems that accessing the filehandle in the for loop is a bad thing.

{ # now read it in with the $fh controling the loop but call
# the =$fh inside the loop inside parens (is this list context??)
my $fh = open($filename);
my $num = 1;
for (=$fh) -> $line {
is($line, "$num\n", '... got the right line ((=$fh) controlled loop)');
$num++;
my $line2 = =$fh;
is($line2, "$num\n", '... got the right line2 ((=$fh) controlled loop)');
$num++;
}
$fh.close();
}


{ # now read it in with the $fh controling the loop but call
# the =$fh inside the loop w/out parens (is this scalar context??)
my $fh = open($filename);
my $num = 1;
for =$fh -> $line {
is($line, "$num\n", '... got the right line (=$fh controlled loop)');
$num++;
my $line2 = =$fh;
is($line2, "$num\n", '... got the right line2 (=$fh controlled loop)');
$num++;
}
$fh.close();
}


However this is not always the case, since this:

{ # now read it in and check
my $fh = open($filename);
for (1 .. 6) -> $num {
my $line = =$fh;
is($line, "$num\n", '... got the right line (array controlled loop)');
}
$fh.close();
}


Runs perfectly well.

IO within a while loop produces a different error (this test taken from t/builtins/io/io_in_while_loop.t)

{ # now read it in with the $fh controling the loop
my $fh = open($filename);
my $num = 1;
my $line;
while ($line = =$fh) {
is($line, "$num\n", '... got the right line (=$fh controlled loop)');
$num++;
}
$fh.close();
}


This will just die with the error:

        pugs: tempfile: hGetLine: end of file

it seems that we are not testing for EOF and returning undef like perl5 would (and I assume that perl6 would too).

I noticed we didnt have any kind of .eof method/function either, I tried to hack one in, but Haskell Cargo Cult is much harder and less forgiving than perl cargo cult so I just 'svn revert'-ed.

- Stevan



Reply via email to