Bug #17101 Updated: Parse errors involving control structures should indicate the start of it
| From: | sander@php.net | Date: | Wed, 08 May 2002 18:54:41 +0000 |
| Subject: | Bug #17101 Updated: Parse errors involving control structures should indicate the start of it | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-7259@lists.php.net to get a copy of this message | ||
ID: 17101
Updated by: sander@php.net
Reported By: destes@ix.netcom.com
-Status: Open
+Status: Closed
Bug Type: Feature/Change Request
Operating System: All
PHP Version: 4.1.2
New Comment:
There is no way how PHP can detect it.
Consider the following (bogus) script:
if($foo) {
...
if($bar) {
...
}
How can PHP know which brace is missing?
It can be
if($foo) {
...
}
if($bar) {
...
}
but it can also be
if($foo) {
...
if($bar) {
...
}
}
If you have a good idea how to detect it, please let us hear.
Previous Comments:
------------------------------------------------------------------------
[2002-05-08 14:36:56] destes@ix.netcom.com
A common scripting oversight is to forget to properly close control
structures bounded by curly braces such as if:
if ($var) {
$foo = 1;
$bar = 2;
/* forgot the } */
...
When parsing this, PHP reports that the error occurred on the last line
of the script - however many lines there are. For scripts that run
many thousands of lines, and contain hundreds of control structures,
this means a huge amount of time spent going over the entire code
looking for the bad structure.
It occurs to me that PHP should be able to determine where the START of
the unended control structure is, and raise the parse error indicating
that line (instead of the last line of the document). Adding this
feature would greatly decrease debug times for people who occasionally
make errors like these.
Thanks,
Steve
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=17101&edit=1