Bug #67757 [Opn]: multiple default cases

From: Date: Tue, 05 Aug 2014 23:32:15 +0000
Subject: Bug #67757 [Opn]: multiple default cases
References: 1  Groups: php.standards 
Request: Send a blank email to standards-+get-353@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=67757&edit=1 ID: 67757 Updated by: joelm@php.net 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: +1 on the spec being the optimal behavior. Don't allow this. PHP5 and HHVM actually differ on behavior here, scarily enough. PHP5 executes the code in the last default. HHVM executes the code in the first default. Previous Comments: ------------------------------------------------------------------------ [2014-08-05 23:21:00] ajf@php.net FWIW, I'm also in favour of fixing implementations here. ------------------------------------------------------------------------ [2014-08-05 23:18:38] pollita@php.net 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] aharvey@php.net 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

« previous php.standards (#353) next »