PS:因为最近很忙,好久没有更新 Blog 了。
最近发现了一个 mxmlc 编译器的 BUG,当含有 -(true ? 1 : 0) 的代码编译会出错。
比如以下代码:
package {
import flash.display.Sprite;
public class TestBUG extends Sprite {
public function TestBUG() {
trace('Test');
var foo:Number = -(true ? 1 : 0);
}
}
}使用 mxmlc 编译时会弹出错误:
Error: null java.lang.NullPointerException at macromedia.asc.semantics.ConstantEvaluator.evaluate(ConstantEvaluator.java:1168) at macromedia.asc.parser.UnaryExpressionNode.evaluate(UnaryExpressionNode.java:33) at macromedia.asc.semantics.ConstantEvaluator.evaluate(ConstantEvaluator.java:1805) ......
但把 -(true ? 1 : 0) 的 - 号去掉后编译却可以正常进行,真奇怪!
影响的版本:
- 2.0
- 2.0.1
- 3.0.0
![[Google]](http://www.google.com/logos/Logo_25wht.gif)
![[Synchronous Space]](http://weihe924stephen.googlepages.com/syncspace-banner.jpg)
![[Creative Commons License]](http://i.creativecommons.org/l/by-nc-sa/3.0/88x31.png)
![[Add to Google]](http://buttons.googlesyndication.com/fusion/add.gif)
![[Aggregated by MXNA]](http://weblogs.macromedia.com/mxna/images/mxna88x31.gif)
![[Flex.org]](http://www.flex.org/images/flexorg.gif)
![Validate my Atom 1.0 feed [Valid Atom 1.0]](http://validator.w3.org/feed/images/valid-atom.png)
![Validate my RSS feed [Valid RSS]](http://resource.googlecode.com/files/valid-rss.png)
![[I heart FeedBurner]](http://www.feedburner.com/fb/images/pub/i_heart_fb.gif)
1 条评论:
Your blog was very useful to me. I encountered same error message. I found the resolution.
Don't modify the result of a ternary operation.
Use below two sentences,
var foo:Number = true ? 1 : 0;
foo = -foo;
instead of your below syntax.
var foo:Number = -(true ? 1 : 0);
发表评论