summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/loadlib.js7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/loadlib.js b/src/loadlib.js
index e7626ab..7a50556 100644
--- a/src/loadlib.js
+++ b/src/loadlib.js
@@ -56,7 +56,12 @@ if (WEB) {
return null;
}
let res = func(fengari);
- return res;
+ if (typeof res === "function" || (typeof res === "object" && res !== null)) {
+ return res;
+ } else {
+ lua.lua_pushstring(L, lua.to_luastring(`library returned unexpected type (${typeof res})`));
+ return null;
+ }
} else {
lua.lua_pushstring(L, lua.to_luastring(`${xhr.status}: ${xhr.statusText}`));
return null;