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

assert() and error() in Lua module loaded by custom package loader raise exception in closure #23

Open
ghost opened this issue Jun 15, 2016 · 0 comments

Comments

@ghost
Copy link

ghost commented Jun 15, 2016

I am trying to use php-lua with a custom package loader loading lua scripts and modules from a remote server. I ran into an issue with assert and error inside my modules. When an assert throws or when I call the Lua error function, php-lua raises an exception:

call to lua function (null) failed
#0 [internal function]: LuaClosure->__invoke()
#1 [internal function]: LuaClosure->__invoke()
#2 /path/to/bug-assert.php(34): Lua->eval('local m = requi...')
#3 {main}

I attached a test case showing this problem. The test case installs a custom package loader load_package which tells Lua to call the PHP run_script function (which in my real application fetches code from a remote server) when a module is required. run_script loads a module which exposes a single function func containing asserts. When the main script calls func any assert that doesn't pass will throw a LuaClosure exception. Same for when the function calls error. If I move the assert to the module's main context, it works as expected.

I tested the 1.1.0 release from PECL and the master branch on GitHub.

bug-assert.phpt

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

0 participants