Bug #80365 [NEW]: Nonsensical error message says "expecting end of file"

From: Date: Fri, 13 Nov 2020 18:49:12 +0000
Subject: Bug #80365 [NEW]: Nonsensical error message says "expecting end of file"
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-230346@lists.php.net to get a copy of this message
From: php4fan at gmail dot com Operating system: all PHP version: 8.0.0RC4 Package: *General Issues Bug Type: Bug Bug description:Nonsensical error message says "expecting end of file" Description: ------------ The script below rightfully results in a parse error, but the error message is garbage. It says 'unexpected token "<"' (so far so good) but then it adds "expecting end of file". End of file is only one out of a pile of possible valid tokens there. I appreciate that you tried to improve on previous versions which would only say "unexpected token [...]" without specifying what valid thing was expected. I myself complained many times about that. It's necessary to always specify not only the unexpected thing but also what was expected instead, at least when the range of possibilities can be reasonably narrowed down. But it makes no sense to name only one random possible valid token and to say you are expecting that one. If the range of valid possibilities is too big to list, just say so. Test script: --------------- <?php echo 3+2; // I'll forget a closing php tag ("? >") now <body> </body> <?php // ... ?> Expected result: ---------------- Parse error: syntax error, unexpected token "<", ... and there you could end with something like: "expecting end of file among other valid possibilities", or "expecting something else (too many possibilities to list them exhaustively)" (and of course "on line 7") Actual result: -------------- Parse error: syntax error, unexpected token "<", expecting end of file in [...] on line 7 -- Edit bug report at https://bugs.php.net/bug.php?id=80365&edit=1 -- Fix committed: https://bugs.php.net/fix.php?id=80365&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=80365&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=80365&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=80365&r=needscript Try newer version: https://bugs.php.net/fix.php?id=80365&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=80365&r=support Expected behavior: https://bugs.php.net/fix.php?id=80365&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=80365&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=80365&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=80365&r=globals PHP version support discontinued: https://bugs.php.net/fix.php?id=80365&r=phptooold Daylight Savings: https://bugs.php.net/fix.php?id=80365&r=dst IIS Stability: https://bugs.php.net/fix.php?id=80365&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=80365&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=80365&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=80365&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=80365&r=mysqlcfg

« previous php.bugs (#230346) next »