闪客动漫天地
欢迎 游客 , 注册 | 登录 | 会员 | 界面 | 简洁版本 | 在线 | 帮助
闪客动漫天地论坛

发表新主题 回复该主题
本主题被查看1338次, 共2个帖子, 1页, 当前为第1页     选择页数: 1      跳转到第   上一主题   下一主题
标题: I find a new compiling bug in Flash 8:
新手上路
UID: 120402
来自:
精华: 0
积分: 4
帖子: 4
注册: 2007-6-13 13:01:00
状态: 离线
威望: 0.00
金钱: 0.85 元
只看楼主 2007-11-14 21:58
I find a new compiling bug in Flash 8:
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.
#1  
新手上路
UID: 120402
来自:
精华: 0
积分: 4
帖子: 4
注册: 2007-6-13 13:01:00
状态: 离线
威望: 0.00
金钱: 0.85 元
只看楼主 2007-11-14 22:00
回复: I find a new compiling bug in Flash 8:
这是一个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>
更有趣的是,若我改为其它运算,如-,*,/,^等等,它们都会出现警告。
请问,有人能给出一个合理的解释么?
#2  
发表新主题 回复该主题
本主题被查看1338次, 共2个帖子, 1页, 当前为第1页     选择页数: 1      跳转到第







现在的时间是 2008-07-25 16:34:57
沪ICP备05003105号

版权所有 闪客俱乐部  
         Powered by Discuz!NT 1.0.6666    Copyright © 2001-2008 Comsenz Inc.
Processed in 0.848 seconds