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

Lua.ToString changes stack if callMetamethod is true #46

Closed
moonwizard opened this issue Mar 24, 2019 · 4 comments
Closed

Lua.ToString changes stack if callMetamethod is true #46

moonwizard opened this issue Mar 24, 2019 · 4 comments

Comments

@moonwizard
Copy link

When using Lua.ToString(index), I was getting unexpected behaviors. I determined that Lua.ToString(index, true) was adding a value to the Lua stack.

After investigation, I discovered that Lua.ToString(index, true) ends up ultimately calling luaL_tolstring in Lua.ToBuffer, which pushes a value onto the stack in addition to returning the buffer value.

My expected behavior of a function called ToString(index) is that it simply returns a string value without modifying the Lua stack, especially since calling ToString(index, false) does not change the Lua stack.

Regards,
JPG

@utkumaden
Copy link

utkumaden commented Mar 25, 2019

Can confirm the issue. The stack was behaving in an unusual way for me, so I changed the indexes to be absolute as a quick fix.

@viniciusjarina
Copy link
Member

Yes. Is a know issue. Not sure what is the best solution in this case, maybe remove the value from stack when callMetamethod is true?

@moonwizard
Copy link
Author

The expectation that I had is that ToString would leave the stack in the original state before the call, regardless of any parameter values. The fact that it changes the stack depending on parameter values is very unexpected.

@viniciusjarina
Copy link
Member

Fixed: 3cb7a26

Thank you for the report.

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

3 participants