Wednesday, October 29, 2008

As3 compiler bug

written by Marcel Panse

I was refactoring some code today in my flex as3 project and ran into a very strange compiler bug. What i did was selecting a bunch of code from a switch statement en pasting it in some other method. When i came to the point the entire switch statement was empty i forgot to remove the statement. As i continued refactoring and came to the point that it actually compiled, but now flex builder was saying:
"An internal build error has occurred. Right-click for more information".

So i check the errors log in eclipse which stated the following error:
Uncaught exception in compiler:
at macromedia.asc.semantics.ConfigurationEvaluator.evaluate(Unknown Source)
at macromedia.asc.parser.SwitchStatementNode.evaluate(Unknown Source)
at macromedia.asc.semantics.ConfigurationEvaluator.evalAndFold(Unknown Source)
at macromedia.asc.semantics.ConfigurationEvaluator.evaluate(Unknown Source)
at macromedia.asc.parser.StatementListNode.evaluate(Unknown Source)...
The parser actually gives a nullpointer exception in the SwitchStatementNode. I removed the switch statements and the error was gone.
var value:int = 0;
If you put that code somewhere in some class in a project, the compiler will start throwing nullpointers and you will probably have a hard time figuring out where the malicious statement is..

I checked the adobe bug database and there already is a report on this issue: stating it is fixed in the next version.