Open wzhengsen opened 1 year ago
I tried the codes in godbolt and the first code does not throw at all.
The second code throws. lua: error: stack index -1, expected table, received nil: value is not a table or a userdata that can behave like one (type check failed in constructor)
GCC 10.1, Lua 5.3.5, Sol 3.2.1
So sounds like both codes may work differently in different environments. Or maybe just different sol or lua versions handle the cases differently,
@Rochet2 I have provided a screen recording to reproduce the bug:
This is my code:
#define SOL_ALL_SAFETIES_ON 1
#define SOL_SAFE_FUNCTIONS 0
#include <sol/sol.hpp>
#include <iostream>
int main() {
std::cout << SOL_VERSION << std::endl;
std::cout << LUA_VERSION << std::endl;
sol::state lua;
try {
sol::function f = lua[""];
f();
}
catch (const sol::error& e) {
std::cout << e.what() << std::endl;
}
try {
sol::table t = lua[""];
}
catch (const sol::error& e) {
std::cout << e.what() << std::endl;
}
return 0;
}
My IDE: Microsoft Visual Studio Community 2022 v17.4.5
The code 1:
The code 2: