Bug 60888 - incorrect warning?
Summary: incorrect warning?
Status: RESOLVED WORKSFORME
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.0   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.0 M9   Edit
Assignee: JDT-Core-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-05-04 10:20 EDT by DJ Houghton CLA
Modified: 2004-05-05 08:56 EDT (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description DJ Houghton CLA 2004-05-04 10:20:52 EDT
build i0504-0800

We have code which looks like the following:
    if (condition)
       methodCall();
    else
       // unknown BOM... ignore it				
       ;
    return result;

We are getting a warning saying that the semi-colon in the "else" stmt is
unncessary. But if we remove it, won't the "return" only be executed in the "else"?
Comment 1 Olivier Thomann CLA 2004-05-04 11:34:16 EDT
In fact the whole else clause is useless. So it is true that the else statement
is useless.
Your code can be written like this:
    if (condition)
       methodCall();
    return result;

And it does the same thing.
Comment 2 DJ Houghton CLA 2004-05-04 11:38:36 EDT
Yep, I realize that. (and am going to address it)

I was just worried about the case where I am going through and removing
deprecations. Blindly removing the semi-colon is actually changing the code
whereas the message sort of implies that its a no-op.
Comment 3 Philipe Mulet CLA 2004-05-04 12:39:43 EDT
Just to clarify: the warning tells you that the statement in ELSE clause 
doesn't need to be nested in ELSE clause, it can be moved right behind.
i.e. tt doesn't mean you should remove entirely the ELSE statement.
Comment 4 DJ Houghton CLA 2004-05-04 12:52:40 EDT
The warning is "Unncessary semicolon" and the code would be broken/changed if I
removed it. (even worse is that removing the semi-colon is the option that Quick
Fix offers me when I hit ctrl-1)

If the warning message was "Empty ELSE statment...consider removing condition"
then that would make sense. (and would allow Quick Fix to suggest the right
correction)
Comment 5 Philipe Mulet CLA 2004-05-05 07:21:33 EDT
Your original comment said you were actually seeing the proper warning. Can 
you clarify what is going on ?
Comment 6 DJ Houghton CLA 2004-05-05 08:56:39 EDT
Sorry, lack of sleep leads to confusing bugzilla reports. :-)

After thinking about it, I'm not sure if the warning message is actually the one
that should appear. I'm not sure what the resolution should be, but either the
message should be changed from "Unnecessary semicolon" to "empty ELSE stmt" or
the Quick-Fix should not remove the semi-colon as a solution to the problem
because it changes the behaviour of the code.