php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #51016 Always associate "else:" followed by colon to an "if:" followed by colon
Submitted: 2010-02-11 14:03 UTC Modified: 2010-11-24 09:41 UTC
Votes:3
Avg. Score:3.0 ± 1.6
Reproduced:1 of 2 (50.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: claude dot pache at gmail dot com Assigned:
Status: Open Package: Scripting Engine problem
PHP Version: 5.3.1 OS: *
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: claude dot pache at gmail dot com
New email:
PHP Version: OS:

 

 [2010-02-11 14:03 UTC] claude dot pache at gmail dot com
Description:
------------
In case of ambiguity, the statements "else" and "elseif" are always 
associated to the last previous "if" or "elseif". This rule is not 
convenable when the else/elseif is followed by a colon and the last 
previous if/elseif is not.

See also: http://bugs.php.net/bug.php?id=838

Reproduce code:
---------------
if(foo):
    // some code here
    if (bar) baz;
else:
    // some code here
endif;

Expected result:
----------------
Since the "else" is followed by a colon (:), it can be associated 
*unambiguously* with the last "if" followed by a colon (here, 
"if(foo):"), and not with the last "if" (here, "if(bar)").


Actual result:
--------------
Parse error. The "else" is associated with the last "if", and the 
following ":" is unexpected.


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2010-11-24 09:41 UTC] jani@php.net
-Package: Feature/Change Request +Package: Scripting Engine problem -Operating System: irrelevant +Operating System: *
 
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Sat Aug 15 02:01:25 2020 UTC