闪客动漫天地论坛

首页 » Flash专区 » 脚本编程技术 » I find a new compiling bug in Flash 8:
Deackie - 2007-11-14 21:58:00
I find a new compiling bug in Flash 8:

function largerThanTen(n:Number):Boolean {
return n>0;
}
trace(largerThanTen(10));


Obviously, we won't, on purpose, change the > symbol(2nd line) into a plus operator. But, what if we want create a function that is used to do sth else but comparing numbers.
I accidentally changed the alter the "Boolean" to "String" and run it. Yes of course the compiler will tell us about a type mismatch out there. However, after I use plus operator, no warning for this kind:

function largerThanTen(n:Number):String {
return n+0;
}
trace(largerThanTen(10));


And what's more interesting is that I've also tried other operators, such as -, *, /, ^, etc., all of which will bring about an error reporting.
Could someone give us a reasonable explanation to this phenomenon?
I would rather classfy it as a compiling bug in Flash 8.
Deackie - 2007-11-14 22:00:00
这是一个Flash 8的编译BUG吧我觉得。
<script>
function largerThanTen(n:Number):Boolean {
return n>0;
}
trace(largerThanTen(10));
</script>

明显,我们不会故意将 > 符号(第2行)错弄成 + 。但是,如果我们其实是想建一个不是用来比较的函数,又怎么办哩?
我当初是偶然把Boolean改为String,然后运行。当然,编译器会告訴我们说有“类型不匹配“,然而当我将 > 改为 + 后,就没有警告了:
<script>
function largerThanTen(n:Number):String {
return n+0;
}
trace(largerThanTen(10));
</script>
更有趣的是,若我改为其它运算,如-,*,/,^等等,它们都会出现警告。
请问,有人能给出一个合理的解释么?
 1 
查看完整版本: I find a new compiling bug in Flash 8: