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

load function regression failure in 1.0 #154

Open
DarkMarmot opened this issue May 7, 2023 · 2 comments
Open

load function regression failure in 1.0 #154

DarkMarmot opened this issue May 7, 2023 · 2 comments

Comments

@DarkMarmot
Copy link

DarkMarmot commented May 7, 2023

I found that my code no longer worked with the 1.0 version here, but works fine with 0.4.

To reproduce (in Elixir, apologies) in 1.0:

iex(1)> {_, chunk, _} = :luerl.load("return 2 + 5", :luerl.init())

In version 0.4, chunk would be:

{:lua_func, 1, 0, [], 1, [{:push_lit, 2.0}, {:push_lit, 5.0}, {:op, :+, 2}, :multiple, {:return, 1}]}

But in 1.0, it's now:

{:funref, 0, []}

Thanks for the library, I've much enjoyed it!

@DarkMarmot
Copy link
Author

I verified that this behavior is still in the develop branch as well.

@rvirding
Copy link
Owner

Yes, this is due to a change in the internals of the Luerl state. In the old state the Lua functions would be directly kept everywhere they were referenced which meant that there could be many copies of a function. Now the functions are kept in a table in the state and referenced through that table using the funref data which means that there is only one copy of each function.

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

2 participants