Req #64594 [Opn->Nab]: case without default should be failed
| From: | nikic@php.net | Date: | Fri, 05 Apr 2013 20:52:33 +0000 |
| Subject: | Req #64594 [Opn->Nab]: case without default should be failed | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-178314@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=64594&edit=1
ID: 64594
Updated by: nikic@php.net
Reported by: vdeepakkumar at msn dot com
Summary: case without default should be failed
-Status: Open
+Status: Not a bug
Type: Feature/Change Request
Package: *Compile Issues
Operating System: ALL
PHP Version: 5.4.13
Block user comment: N
Private report: N
New Comment:
No way this is going to happen. PHP's switch allows fall-through and intentionally so. Same way
it works in nearly any other language implementing switch.
Previous Comments:
------------------------------------------------------------------------
[2013-04-05 20:18:38] vdeepakkumar at msn dot com
Description:
------------
When we have switch case statements and when case statements are skipped of break
statement inadvertantly the page/control would fail. Similar to C#, php compiler
should throw an error 'Control can not fall through case constructs'.
Test script:
---------------
switch ($t)
{
case "t":
echo "test";
case "e":
echo "e test";
}
Expected result:
----------------
It should fail with parse error and the user correction should be
switch ($t)
{
case "t":
echo "test";
break;
case "e":
echo "e test";
break;
}
Actual result:
--------------
It should fail with parse error and the user correction should be
switch ($t)
{
case "t":
echo "test";
break;
case "e":
echo "e test";
break;
}
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=64594&edit=1