Fix semantics of check_get for objects obtained by proxy

This commit is contained in:
ThePhD 2018-03-04 10:56:05 -05:00
parent e8e5ddc890
commit e8119ec9a3
2 changed files with 4 additions and 3 deletions

View File

@ -77,5 +77,6 @@ int main(int, char**) {
lua.script("check_f_env(f)");
lua.script("check_g_env(g)");
return 0;
}

View File

@ -52,11 +52,11 @@ namespace stack {
template <typename Handler>
static optional<T> get(lua_State* L, int index, Handler&& handler, record& tracking) {
// actually check if it's none here, otherwise
// we'll have a nil object inside an optional!
bool success = !lua_isnoneornil(L, index);
// we'll have a none object inside an optional!
bool success = !lua_isnone(L, index);
if (!success) {
// expected type, actual type
tracking.use(static_cast<int>(!lua_isnone(L, index)));
tracking.use(static_cast<int>(success));
handler(L, index, type::poly, type_of(L, index), "");
return nullopt;
}