Priority
Critical
Type
Bug 
State
Fixed 
Assignee
Maxim Shafirov 
Subsystem
Code Analysis. Inspection 
Affected versions
Fixed in
Fixed in build
Next build 
Build
7123
Fixed in build
8099
Severity
0
  • Submitted by   Jonas Kvarnstrom
    2 years ago (21 Aug 2007 12:00)
  • Updated by   root
    3 weeks ago (17 Jan 2010 19:51)
  • Jira: IDEA-40483
    (history, comments)

IDEA-40483

Quickfix for "condition is always true" mangles code, changes semantics

0
In the following class, "args = null) {
System.out.println("Args");
System.out.println("Args again");
}
}
}{

Accepting the quickfix at "args != null" leads to the following:

{
}package test;

// 7.0M2
public class TestIfElseFix
{
public static void main(String[] args) {
if (args.length == 0) {
System.out.println("No args");
} else System.out.println("Args");
System.out.println("Args again");
}
}{{code}}

Notice that the braces are gone and "Args again" will always be printed. Depending on the original layout of the code it can be easy for this to slip by, introducing subtle bugs.



Issue was resolved
Comments (1)
 
History (1)
 
Links
 
Jonas Kvarnstrom
  Jonas Kvarnstrom
11 Jan 2008 15:44
(2 years ago)
#permalink
Still present; I hope it will be fixed in 7.0.x since it changes the semantics of the code in a way you could easily miss.