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

[v4] sol::stack::check, sol_lua_check changes and improvements #1260

Open
ThePhD opened this issue Oct 23, 2021 · 0 comments
Open

[v4] sol::stack::check, sol_lua_check changes and improvements #1260

ThePhD opened this issue Oct 23, 2021 · 0 comments
Assignees
Milestone

Comments

@ThePhD
Copy link
Owner

ThePhD commented Oct 23, 2021

Right now, sol_lua_check and sol::stack::check work by using a handler-based approach that invokes some sort of error handling operation, which is expected to jump or throw or terminate. These are not useful modes of continuation, and definitively cause excessive failures that are hard to track (see #1144, #1174, #1183, #1078, #1072, #965, #1038 and more).

The fix for this is to change how sol::stack::check, sol_lua_check, and the error handlers work. This can also be used to improve the situation for returning if an error actually happens checking, and make the protect and code more streamlined. It will look like so:

struct check_error {
     std::string error_reason;
};

std::optional<check_error> sol_lua_check(sol::types<T> type, lua_State* L, int index,
                                                               std::function<sol::check_handler_type> handler,
                                                               record& tracking);

This means that the bool return from before is no longer viable. As a general upgrade path, we will likely allow old code to work. But, this might mean fundamentally destroying the way sol_lua_check_get has to operate, since we need to return an error better rather than always simply panicking in a handler.

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

No branches or pull requests

1 participant