Re: [RFC] Disallow multiple default blocks in a single switch statement
| From: | Rowan Collins | Date: | Wed, 13 Aug 2014 13:42:23 +0000 |
| Subject: | Re: [RFC] Disallow multiple default blocks in a single switch statement | ||
| References: | 1 2 3 4 5 6 7 8 9 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-76484@lists.php.net to get a copy of this message | ||
Ferenc Kovacs wrote (on 13/08/2014):
It is not selecting the first default, it just never needs to look
for a default, because it has already found a matching case label.
yes, and it continues the execution from the first matching case and correctly evaluates the following defaults, as default matches everything, which imo should be the correct behavior.
No, it does not "evaluate the following defaults"; it evaluates all following code. Once a label has been selected, you can think of all subsequent labels being removed from the code completely.
having a different behavior for default when there is a preceeding matching empty case is not the expected(from the userland point of view) behavior imo.There is no different behaviour. Labels which do not match the input have no effect on execution, and default labels have no effect if any other label matched.