This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 258864 - Cannot name the same some variable inside a case (switch statement) if the cases are not surrounded with { }
Summary: Cannot name the same some variable inside a case (switch statement) if the ca...
Status: RESOLVED INVALID
Alias: None
Product: ide
Classification: Unclassified
Component: Code (show other bugs)
Version: 8.1
Hardware: PC Windows 10
: P4 normal (vote)
Assignee: issues@ide
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-04-16 08:05 UTC by jh62
Modified: 2016-04-22 10:57 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description jh62 2016-04-16 08:05:31 UTC
Product Version = NetBeans IDE 8.1 (Build 201510222201)
Operating System = Windows 10 version 10.0 running on amd64
Java; VM; Vendor = 1.8.0_65
Runtime = Java HotSpot(TM) 64-Bit Server VM 25.65-b01

Reproducibility: Happens every time

1- This says that variable "x" is already defined:

switch(value){
 case 1:
 int x = 0;
 break;
case 2:
 int x = 0;
 break;
}

2 - This is ok:

switch(value){
 case 1:
{
 int x = 0;
 break;
}
case 2:
{
 int x = 0;
 break;
}
}

I dont know if this behaviour is to be expected because of some programming rule i dont know
Comment 1 Jiri Prox 2016-04-22 10:57:43 UTC
This is expected behavior, case statement does not create separate block.