-
Notifications
You must be signed in to change notification settings - Fork 2
Open
Description
This is an example taken directly from busted documentation:
local t = {
greet = function(msg) print(msg) end
}
stub(t, "greet")
t.greet("Hey!") -- DOES NOT print 'Hey!'
assert.stub(t.greet).was.called_with("Hey!")Lua LS gives the following error on the assertion line:
Diagnostics:
Cannot assign `function` to parameter `luassert.spy`.
- `function` cannot match `luassert.spy`
- Type `function` cannot match `luassert.spy` [param-type-mismatch]
I'm not sure how to fix this. Changing the param in the meta file to luassert.spy|function may be a workaround but would not be accurate. The problem is that t.greet is already a luassert.spy object but the language server incorrectly assumes that it is a function. The object is modified in-place and after the call:
local s = stub(t, "greet")t.greet is no longer a function but a callable table. Both s and t.greet point to the same object (of type luassert.spy). It would be best if the language server could figure this out.
Metadata
Metadata
Assignees
Labels
No labels