Bug #76568 [Opn->Nab]: For loop does not through error when Left bracket does not follow right paren

From: Date: Tue, 03 Jul 2018 03:39:06 +0000
Subject: Bug #76568 [Opn->Nab]: For loop does not through error when Left bracket does not follow right paren
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-216090@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=76568&edit=1 ID: 76568 Updated by: requinix@php.net Reported by: andrew dot marek at sbcglobal dot net Summary: For loop does not through error when Left bracket does not follow right paren -Status: Open +Status: Not a bug Type: Bug Package: Scripting Engine problem Operating System: CENTOS 6.4 PHP Version: 5.6.36 Block user comment: N Private report: N New Comment: We aren't Python. Indentation is not syntax. If you write valid syntax that doesn't do what you want, that's on you. Previous Comments: ------------------------------------------------------------------------ [2018-07-02 23:53:36] spam2 at rhsoft dot net and without the continue nobody knows why it is there nothing but an undefined var [harry@srv-rhsoft:/downloads]$ php test.php Notice: Undefined variable: ncountp in /mnt/data/downloads/test.php on line 2 ------------------------------------------------------------------------ [2018-07-02 23:51:03] spam2 at rhsoft dot net this code is simply wrong in supported versions [harry@srv-rhsoft:/downloads]$ php test.php Fatal error: 'continue' not in the 'loop' or 'switch' context in /mnt/data/downloads/test.php on line 12 [harry@srv-rhsoft:/downloads]$ php -v PHP 7.2.7-thelounge-sandybridge (cli) (built: Jul 2 2018 19:28:18) ( NTS ) Copyright (c) 1997-2018 The PHP Group Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies ------------------------------------------------------------------------ [2018-07-02 22:48:20] andrew dot marek at sbcglobal dot net Description: ------------ Note below that the For loop's left bracket does not immediately follow the for loop conditional's right closing bracket. The interpreter does not throw an error and permits this code to execute. Result: For loop does nothing - whether it tries to execute, gets confused, or simply ignores the code - I don't know - the actual result is the program runs and the For loop fails. Fix: Once the interpreter detects a for loop the syntax checker should demand an opening bracket to immediately follow the closing paren on the for loop's conditional. Test script: --------------- for ($ib = 0; $ib < $ncountp; $ib = $ib + 14) $ib1 = $ib + 1; $ib2 = $ib + 2; $ib3 = $ib + 3; $ib4 = $ib + 4; $ib5 = $ib + 5; $ib6 = $ib + 6; $ib7 = $ib + 7; $ib8 = $ib + 8; $ib9 = $ib + 9; $ib10 = $ib + 10; $ib11 = $ib + 11; {$ib12 = $ib + 12; $ib13 = $ib + 13; if (isset($ivcarrp[$ib13])) {if ($ivcarrp[$ib13] == "XX") {$bypasscnt++; continue;} } } ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=76568&edit=1

« previous php.bugs (#216090) next »