繁体   English   中英

Haxe -> JS switch 语句分支错误(Haxe -> Flash 的相同代码工作正常),为什么?

[英]Haxe -> JS switch statement branches wrong (Haxe -> Flash of same code works fine), why?

我一直无法完全隔离地重现这一点,但这是我项目中一些 Haxe 代码的实际屏幕截图:

带有行号的代码列表

我会说如果第 567 行输出“真”作为它的最后一个值,那么下一个跟踪应该是“正确的”,而不是“错误的”。 当我转换为 Flash(使用 haxe 3.2.1)时,就是这样。 但是,转换为 html5,我在 Firefox 或 Chrome 的控制台中得到了这个:

State_Play.hx:567: fairy_destination,true
State_Play.hx:572: wrong,fairy_destination,true

我的问题:这怎么可能?

生成的 JS 代码似乎很合理:

haxe_Log.trace(this._ui.get_currMode(),{ fileName : "State_Play.hx", lineNumber : 567, className : "State_Play", methodName : "clickMap", customParams : [this._ui.get_currMode() == "fairy_destination"]});
var _g2 = this._ui.get_currMode();
switch(_g2) {
case "fairy_destination":
    haxe_Log.trace("right",{ fileName : "State_Play.hx", lineNumber : 570, className : "State_Play", methodName : "clickMap", customParams : [this._ui.get_currMode(),this._ui.get_currMode() == "fairy_destination"]});
    break;
default:
    haxe_Log.trace("wrong",{ fileName : "State_Play.hx", lineNumber : 572, className : "State_Play", methodName : "clickMap", customParams : [this._ui.get_currMode(),this._ui.get_currMode() == "fairy_destination"]});
}

我认为您确实需要创建一个使用http://try.haxe.org/失败的测试,那么帮助起来会容易得多。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM