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 242435 - "The assigned value is never used" after "if (true) return;" statement
Summary: "The assigned value is never used" after "if (true) return;" statement
Status: RESOLVED WONTFIX
Alias: None
Product: java
Classification: Unclassified
Component: Hints (show other bugs)
Version: 8.0
Hardware: PC Windows 7
: P3 normal (vote)
Assignee: Svata Dedic
URL:
Keywords:
Depends on:
Blocks: 249320
  Show dependency tree
 
Reported: 2014-02-27 23:05 UTC by kris001
Modified: 2016-07-07 07:16 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
Screen shot (6.09 KB, image/png)
2014-02-27 23:05 UTC, kris001
Details

Note You need to log in before you can comment on or make changes to this bug.
Description kris001 2014-02-27 23:05:11 UTC
Created attachment 145648 [details]
Screen shot

Following an "if (true) return;" statement, all following assignments get "Unused Assignment" warnings rather than some sort of error about unreachable code 

This is not the case when there is a corresponding else, or the if condition is not trivial 


String test() {
	if (true) {
		return null;
	}
	String s = "foo";
	return s;
}
String test2() {
	if (true) {
		return null;
	} else {}
	String s = "foo";
	return s;
}

String test3() {
	if (1 == 1) {
		return null;
	}
	String s = "foo";
	return s;
}
Comment 1 Svata Dedic 2015-09-10 14:19:46 UTC
Caused by an optimization in the current implementation of flow analysis. I would rather join the fix with reimplementation of the flow/npe check.
Comment 2 Martin Balin 2016-07-07 07:16:14 UTC
This old bug may not be relevant anymore. If you can still reproduce it in 8.2 development builds please reopen this issue.

Thanks for your cooperation,
NetBeans IDE 8.2 Release Boss