Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Passing a sol::table fails as a parameter for usertype ctor #74

Open
Nava2 opened this issue Feb 17, 2016 · 2 comments
Open

Passing a sol::table fails as a parameter for usertype ctor #74

Nava2 opened this issue Feb 17, 2016 · 2 comments

Comments

@Nava2
Copy link

Nava2 commented Feb 17, 2016

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

@Nava2
Copy link
Author

Nava2 commented Feb 17, 2016

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\" }");

@ThePhD
Copy link
Contributor

ThePhD commented Feb 19, 2016

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants