Bug 36452

Summary: Compiler: variable declaraion statment as if body
Product: [Eclipse Project] JDT Reporter: Martin Aeschlimann <martinae>
Component: CoreAssignee: JDT-Core-Inbox <jdt-core-inbox>
Status: RESOLVED WORKSFORME QA Contact:
Severity: normal    
Priority: P3    
Version: 2.1   
Target Milestone: 3.0 M1   
Hardware: PC   
OS: Windows XP   
Whiteboard:

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).