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 270238

Summary: Hint "The assigned value is never used" shown while variable is used in switch statement
Product: java Reporter: MCEmperor
Component: HintsAssignee: Svata Dedic <sdedic>
Status: NEW ---    
Severity: normal    
Priority: P3    
Version: 8.1   
Hardware: PC   
OS: Windows 10 x64   
Issue Type: DEFECT Exception Reporter:

Description MCEmperor 2017-03-29 07:05:15 UTC
Hint "The assigned value is never used" is shown when the value is overwritten by a statement in the switch statement.

    boolean someCondition = true;
    int someInt = 4;
		
    String value = "initialValue";
    if (someCondition) {
        switch (someInt) {
            case 4:
                value = "anotherValue";
                break;
            default:
                throw new IllegalArgumentException();
        }
    }
    System.out.println(value);

The hint occurs at the line

    value = "anotherValue";

but if you run this code, the text "anotherValue" is printed to stdout.