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

No arg error thrown for bool stack get #82

Open
Mellnik opened this issue Mar 31, 2023 · 4 comments
Open

No arg error thrown for bool stack get #82

Mellnik opened this issue Mar 31, 2023 · 4 comments
Labels
bug Something isn't working

Comments

@Mellnik
Copy link

Mellnik commented Mar 31, 2023

Stack<bool>::get does not check whether an actual value exists on stack. This results in LuaBridge silently treating a no value as a valid bool and not throwing any error.

See for example Stack<float> which has a check and reports if a non-float value (or no value) is on stack.

@kunitoki
Copy link
Owner

kunitoki commented Apr 1, 2023

Thanks for reporting, should be pretty trivial to fix.

@kunitoki
Copy link
Owner

kunitoki commented Apr 1, 2023

This poses a question, is LUA_TNIL castable to bool ? Much like how you would cast a pointer to bool to check its validity, this could be debatable.

We might want a strict mode for Stack get, but this will also make it more complex.

@kunitoki kunitoki added the bug Something isn't working label Apr 1, 2023
@Mellnik
Copy link
Author

Mellnik commented Apr 2, 2023

Hm, in such case I would always check what the default Lua behavior is.

http://lua-users.org/wiki/ExpressionsTutorial
Logical operators

@rpatters1
Copy link
Contributor

rpatters1 commented Apr 3, 2023

My code expects absent bools (i.e., LUA_TNONE) to get passed into C++ as false. This is LB2 behavior, and it is standard Lua behavior. If you are going to implement a fix, I would request an opt-out.

That said, I have one or two constructors where I would really like to be able to force the programmer to supply the boolean. But I can do that with a proxy constructor.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants