Mantis - Quercus
Viewing Issue Advanced Details
2879 minor always 08-28-08 23:56 09-03-08 23:47
koreth  
nam  
normal  
closed 3.2.1  
fixed  
none    
none 3.2.1  
0002879: Bogus "break" causes compilation failure
<?php
function foo($id) {
  if ($id == 1) {
    break;
  }
  return null;
}


That's obviously a bogus "break" (and this Quercus bug uncovered a case like this in our code base) but the above fails to compile. The generated Java code has two "return" statements in a row which causes an "unreachable statement" error.

Not high priority at all; the offending PHP code can and should be fixed to not tickle this bug.

Notes
(0003376)
nam   
09-03-08 23:47   
php/3646

A break/continue inside a function, that is not enclosed by a loop/switch, is not allowed in PHP:

PHP 5.2.4: Fatal error: Cannot break/continue 1 level

Quercus will now report this parse error, instead of just executing the code.