Bug #79368 [Opn]: "Unexpected end of file" is not an acceptable error message

From: Date: Wed, 11 Mar 2020 23:11:52 +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-226042@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 Updated by: requinix@php.net 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: Hopefully I'm not adding fuel to the fire, but exactly what error message should this code produce? <?php class Example { public static function doThing($param) { if ($param) { echo "Doing the thing"; } } Previous Comments: ------------------------------------------------------------------------ [2020-03-11 22:27:18] rowan dot collins at gmail dot com Hi, While bug reports and feature requests are always welcome, please keep in mind that PHP is not a commercial product, so you are asking people to volunteer their time and expertise to improve it. If you help those volunteers understand your request, and make clear that you appreciate their efforts, you're more likely to get their help in return. The other thing to keep in mind is that PHP has been actively developed for 25 years. While it's possible that nobody got around to making these messages better, it's probably more likely that the problem is harder than you think. If you know how the parser works and would like to contribute an improvement, I'm sure it would be very welcome; if you don't, you may not be the best judge of how easy it would be to do. Just to be clear: I'm not an expert on the parser either; and I agree the message could be more helpful. I wouldn't call it "not acceptable" though, because I've been a programmer long enough to know that some things are more difficult than they look. Regards, Rowan Tommins [IMSoP] ------------------------------------------------------------------------ [2020-03-11 19:39:49] bugreports at gmail dot com > And btw, it's not just not closing something that you've opened. > > For example this: > > ``` > <?php > > $s = > ``` surely, you opened an assignment and never finished it so from the view of a parser everyting after it is part of the assignment until ; appears and then averything after "that line" to ; makes little to no sense ------------------------------------------------------------------------ [2020-03-11 19:17:17] php4fan at gmail dot com > 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 = ``` ------------------------------------------------------------------------ [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. ------------------------------------------------------------------------ The remainder of the comments for this report are too long. To view the rest of the comments, please view the bug report online at https://bugs.php.net/bug.php?id=79368 -- Edit this bug report at https://bugs.php.net/bug.php?id=79368&edit=1

« previous php.bugs (#226042) next »