Open s-ol opened 5 years ago
This seems to be a minifier bug. For some reason,
"typeof": function(L) {
let u = tojs(L, 1);
lua_pushliteral(L, typeof u);
return 1;
}
is getting compiled to:
"typeof": function _typeof(L) {
var u = tojs(L, 1);
lua_pushliteral(L, _typeof(u));
return 1;
}
Which ends up calling itself with invalid parameters.
Next steps:
typeof
directlyI've got the same issue, and it also seems to affect instanceof
(same issue of calling itself instead of the internal function), so there is currently no way to check JS types from Lua. I'm working on a pull request right now, and aliasing it to jstypeof
seems to work, though I haven't gotten jsinstanceof
working yet.
Update: So instanceof
was working after all, I just forgot to use class objects instead of strings on the right-hand side. Can't create pull requests, but the following code seems to fix typeof
seamlessly.
"jstypeof": function(L) {
let u = tojs(L, 1);
lua_pushliteral(L, typeof u);
return 1;
}
};
jslib["typeof"] = jslib["jstypeof"];
Minimal example, e.g. in the https://fengari.io REPL: