Bug 36452 - Compiler: variable declaraion statment as if body
Summary: Compiler: variable declaraion statment as if body
Status: RESOLVED WORKSFORME
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 2.1   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.0 M1   Edit
Assignee: JDT-Core-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2003-04-14 09:31 EDT by Martin Aeschlimann CLA
Modified: 2003-06-02 06:12 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 Martin Aeschlimann CLA 2003-04-14 09:31:18 EDT
2.1
The following code does not compile ('[' or '.' expected). Is that a bug?

  public void a() {
	if (true)
		int xxxx= 0; 	
  }

When changed to
  public void a() {
	if (true) {
		int xxxx= 0;
        }
  }
no problems.
Comment 1 Philipe Mulet CLA 2003-04-14 10:34:06 EDT
Variable declarations can only occur as block statements.
You thus need to wrap it inside a block.

We correctly detect this (as other compilers do).