diff options
author | daurnimator <quae@daurnimator.com> | 2017-11-28 00:46:24 +1100 |
---|---|---|
committer | daurnimator <quae@daurnimator.com> | 2017-11-28 00:46:24 +1100 |
commit | c8d6c4323c62c38a4fad40642cd9db166caa910a (patch) | |
tree | 8ce53569ec9823948a94024e340847f50d8668e0 /src | |
parent | aa1a44c84f11f97f6614b9c2fd252fddec4067eb (diff) | |
download | fengari-c8d6c4323c62c38a4fad40642cd9db166caa910a.tar.gz fengari-c8d6c4323c62c38a4fad40642cd9db166caa910a.tar.bz2 fengari-c8d6c4323c62c38a4fad40642cd9db166caa910a.zip |
src/lauxlib.js: Fix missing 'else' in luaL_getmetafield
Diffstat (limited to 'src')
-rw-r--r-- | src/lauxlib.js | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/src/lauxlib.js b/src/lauxlib.js index 62fc6f3..518190f 100644 --- a/src/lauxlib.js +++ b/src/lauxlib.js @@ -437,14 +437,16 @@ const luaL_dostring = function(L, s) { }; const luaL_getmetafield = function(L, obj, event) { - if (!lua.lua_getmetatable(L, obj)) + if (!lua.lua_getmetatable(L, obj)) /* no metatable? */ return lua.LUA_TNIL; else { lua.lua_pushstring(L, event); let tt = lua.lua_rawget(L, -2); - if (tt === lua.LUA_TNIL) - lua.lua_pop(L, 2); - return tt; + if (tt === lua.LUA_TNIL) /* is metafield nil? */ + lua.lua_pop(L, 2); /* remove metatable and metafield */ + else + lua.lua_remove(L, -2); /* remove only metatable */ + return tt; /* return metafield type */ } }; |