Skip to content

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

Description

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

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions