develooper Front page | perl.perl5.porters | Postings from August 2012

[perl #114104] bogus error message for unterminated heredoc terminator

Thread Previous
From:
Father Chrysostomos via RT
Date:
August 2, 2012 00:36
Subject:
[perl #114104] bogus error message for unterminated heredoc terminator
Message ID:
rt-3.6.HEAD-11172-1343892999-1368.114104-15-0@perl.org
On Thu Jul 12 03:10:38 2012, l.mai@web.de wrote:
> 
> This is a bug report for perl from l.mai@web.de,
> generated with the help of perlbug 1.39 running under perl 5.16.0.
> 
> 
> -----------------------------------------------------------------
> [Please describe your issue here]
> 
> #!perl
> $_ = <<"foo
> foo
> foo
> 
> __END__
> 
> Can't find string terminator "foo
> " anywhere before EOF at foo.pl line 2.
> 
> The error message is bogus because there are in fact two "foo\n"'s in
>    the code.
> The real problem is that there is no second '"' to terminate the
>    heredoc
> terminator. This error message should be improved.

There heredoc-scanning code doesn’t care if the delimiter is missing.

So it ends up using everything up to the end of the buffer as its
terminator ("foo\n").  And then bug #114102 kicks in, preventing it from
seeing "\nfoo\n\n".  The real bug here is that scan_heredoc doesn’t
check that delimcpy actually found the final delimiter.

With string eval, I get to see the implicit ; that gets tacked on to the
end of the buffer:

#!perl
eval'
$_ = <<"foo
foo
foo

__END__
'
or die
__END__

This gives me:

Can't find string terminator "
foo
foo
foo

__END__

;" anywhere before EOF at (eval 1) line 2.
	...propagated at - line 2.

-- 

Father Chrysostomos


---
via perlbug:  queue: perl5 status: open
https://rt.perl.org:443/rt3/Ticket/Display.html?id=114104

Thread Previous


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