Issue with global primitives
I stumbled upon an issue where I cannot reference any of the global primitives in my haxe code. It seems they are not available when the code is running in the browser.
Do you have any idea on how to tackle this?
class Test {
static function main() {
var value:Dynamic = true;
var bool:Bool = cast(value,Bool);
trace(bool);
}
}
Error in the browser console :
bundle.js:20 Uncaught ReferenceError: Bool is not defined
I believe the issue is that this block of globalInit code below does not work as expected. I think none of the classes have access to these declarations, because they run in their own close after being loaded via require. This differs from the standard javascript output, where all of the code runs in the same closure.
Have you stumbled upon this issue before?
// Init code for Std
{
String.prototype.__class__ = String;
String.__name__ = true;
Array.__name__ = true;
var Int = { __name__ : ["Int"]};
var Dynamic = { __name__ : ["Dynamic"]};
var Float = Number;
Float.__name__ = ["Float"];
var Bool = Boolean;
Bool.__ename__ = ["Bool"];
var Class = { __name__ : ["Class"]};
var Enum = { };
}
I did hit this issue. But I'm not actively using Haxe anymore.
This block of code is put out by the Haxe Compiler. I tried to find an elegant way to not give a code block but could not figure it out.
I think I worked around it by not using casting/reflection. If you make a patch to strip off the curly braces, I'll accept it.