Bug #67757 [Opn]: multiple default cases

[email protected]
Newsgroups php.standards
Message-ID <[email protected]>
Edit report at https://bugs.php.net/bug.php?id=67757&edit=1

 ID:                 67757
 Updated by:         [email protected]
 Reported by:        php at tutteli dot ch
 Summary:            multiple default cases
 Status:             Open
 Type:               Bug
 Package:            PHP Language Specification
 PHP Version:        5.5.15
 Block user comment: N
 Private report:     N

 New Comment:

FWIW, I'm also in favour of fixing implementations here.


Previous Comments:
------------------------------------------------------------------------
[2014-08-05 23:18:38] [email protected]

I'd argue that we can look at this either way.

It's kind of silly to allow the definition of two defaults in a switch statement, so the question is: Do we define silliness as normal and update the spec, or do we fix a weirdness in the implementation by updating the engine.

I for one, vote for the latter.

------------------------------------------------------------------------
[2014-08-05 19:19:15] [email protected]

This is probably an issue with the spec, then: AIUI, the spec should be documenting what 5.6 does at present.

------------------------------------------------------------------------
[2014-08-04 12:31:30] php at tutteli dot ch

Description:
------------
PHP allows to define multiple default cases in a switch. According to the spec this should not be allowed:
https://github.com/php/php-langspec/blob/master/spec/11-statements.md#the-s
witch-statement


Test script:
---------------
<?
$a=1;
$b=0;
switch($a) {
  default:
    $b += 1;
    break;
  default:
    $b += 2;
}
echo $b; //output would be 2
?>

Expected result:
----------------
parser syntax error



------------------------------------------------------------------------



--
Edit this bug report at https://bugs.php.net/bug.php?id=67757&edit=1
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.