sol
sol copied to clipboard
Passing a `sol::table` fails as a parameter for `usertype` ctor
Currently, sol fails to pass a sol::table as a parameter to a usertype.
Minimum example:
class Foo {
public:
Foo(sol::table /*table*/) { }
};
int main() {
sol::state lua;
lua.new_usertype<Foo, sol::table>("Foo");
lua.script("a = Foo.new { a = \"wat\" }");
}
The error message is: lua: error: No matching constructor for the arguments provided
Interestingly, this works fine:
_lua.set_function("test_table", [](sol::table table) {
std::string a = table["a"];
std::cout << "table.a = " << a << std::endl;
});
_lua.script("test_table { a = \"wat\" }");
There was a bug in the logic for detecting whether or not a table was called with .new versus :new. This is fixed in sol2.