Bug #79368 [Opn]: "Unexpected end of file" is not an acceptable error message
| From: | php4fan at gmail dot com | Date: | Wed, 11 Mar 2020 19:17:17 +0000 |
| Subject: | Bug #79368 [Opn]: "Unexpected end of file" is not an acceptable error message | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-226036@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=79368&edit=1
ID: 79368
User updated by: php4fan at gmail dot com
Reported by: php4fan at gmail dot com
Summary: "Unexpected end of file" is not an acceptable error
message
Status: Open
Type: Bug
Package: *General Issues
Operating System: all
PHP Version: 7.4.4RC1
Block user comment: N
Private report: N
New Comment:
> to tell you something specific it needs to be parsed
Then how comes you are able to give sensible error messages in other cases?
> "Unexpected end of file" is pretty clear! you are opening more stuff with
> { as you close with }
It could be {, it could be ( or [, even "... and then you have to find which one.
And btw, it's not just not closing something that you've opened.
For example this:
```
<?php
$s =
```
Previous Comments:
------------------------------------------------------------------------
[2020-03-11 18:30:33] bugreports at gmail dot com
> Well, I expect it to tell me why the input is unparseable
to tell you something specific it needs to be parsed
> By your reasoning, no userful error message would ever be given by any parser for any syntax
> error
"Unexpected end of file" is pretty clear! you are opening more stuff with { as you close
with }
------------------------------------------------------------------------
[2020-03-11 18:10:51] php4fan at gmail dot com
> Please provide a concrete test case.
You could have easily created one just with the information provided in my report, but here is one:
```
<?php
if(
```
And here's another (see if you can spot the actual error, then imagine it being in a
real-life-size file)
```
<p class="comment">
<span class="comment_text"><?php echo $comment->text; ?></span>
<?php
if (true) {
?>
<span class="comment_edit_links">
</span>
<?
}
?>
</p>
```
> how do you imagine a parser giving you somnething useable in case of *unparseable input*
Well, I expect it to tell me why the input is unparseable.
By your reasoning, no userful error message would ever be given by any parser for any syntax error.
------------------------------------------------------------------------
[2020-03-11 17:44:32] nikic@php.net
Please provide a concrete test case.
------------------------------------------------------------------------
[2020-03-11 17:10:35] bugreports at gmail dot com
how do you imagine a parser giving you somnething useable in case of *unparseable input*
------------------------------------------------------------------------
[2020-03-11 16:52:35] php4fan at gmail dot com
Description:
------------
"Unexpected <whatever>" alone is NEVER an acceptable error message.
You have to tell me what you were expecting instead of what you unexpectedly found, like:
"Unexpected XXXX. YYY or ZZZ expected". If that is tricky because the spectrum of legal
things that could be expected is too broad, then give a hint or some context: "Unexpected X in
Y", "Unmatched <this>", "incomplete <that>"...
This is especially egregious with "unexpected end of file", which is usually caused by
very trivial errors such an unclosed parenthesis, bracket, brace... but becomes impossible to debug
with such an uninformative error message. (Unexpected end of file at line 999999 meaning the error
can anywhere in a million lines)
It's unbelievable that to this day such an error message is still a thing.
"Unexpected end of file in 'if' condition / function body / whatever".
You can easily do better than just "unexpected end of file".
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=79368&edit=1