test gireg.callback_simple() fails "in the wrong way"
Nobody has claimed this yet.
- Dominant language
- Lua
- Stars
- 491
- Forks
- 81
- PR merge metrics
- No merged PRs in 30d
Description
The test does check(not pcall(R.test_callback, 1)) where test_callback expects an argument of type typedef int (*RegressTestCallback) (void);. I guess the intention here is to have the "attempt to call number value"-error be the reason that the call fails. However, that error is just printed:
(process:24903): Lgi-WARNING **: Error raised while calling 'lgi.cbk (number): Regress': attempt to call a number value
The error that is caught by the pcall is:
tests/gireg.lua:1356: bad argument #5 to '?' (number expected, got nil)
This error happens while trying to marshal the return value of the closure to C. Since the Lua call failed, there is no return value to marshal, thus a nil value is marshalled in closure_callback (actually: check_number which calls luaL_checknumber). This fails with the error above, which is in turn caught by the pcall.
I do not think that this was the intention behind the test (and this is why the build for #183 failed (but only on Lua 5.1, I guess other Lua versions have some other kind of error handling in coroutines and somehow "throw the error" on the "original" coroutine? I think I read somewhere that unprotected errors on a coroutine are re-thrown on the main thread...)
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with tests/gireg.lua around the check at line 1356 and trace R.test_callback through closure_callback and check_number. Run the gireg callback test under Lua 5.1, then compare the pcall error with the warning from lgi.cbk. Done means the test reliably observes the intended callback failure rather than an incidental nil return-marshalling error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- c, lua
- Domain
- backend, testing-qa
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100