Var a's scope is the whole function, thus the duplicate variable
warning.

 

However, the assignment is subject to the conditional.  If the condition
is not satisfied the assignment does not happen and var a is null.

 

Tracy

 

________________________________

From: [email protected] [mailto:[EMAIL PROTECTED] On
Behalf Of lynxoid7
Sent: Thursday, July 24, 2008 10:50 AM
To: [email protected]
Subject: [flexcoders] Weird compiler/debugger issue

 

I ran into this yesterday and so far have not figured out what's the
problem. So I have this piece of code:

private function foo(value:XMLList):void{
trace("foo");
if (value == null || value.length() == 0)
// a comment line here
// another comment here

var a:Object = new Object();
var b:Object = new Object();
var a:Object = new Object();
....
}

compiler issues a warning that a is defined twice, however, when I
debug this code, debugger skips the very first line of code after the
comment lines leaving a uninitialized. Had I not inited a the second
time, I'll get a runtime null pointer exception. Have anyone run into
anything similar? My guess is that somewhere some cache doesn't get
deleted/updated, however, I tried "Clean", tried removing some cache
files, tried deleting and creating the project.

 

Reply via email to