Closed
Description
Penlight comes with the ability to inject a format operator into string's __mod
metamethod. This greatly shortens creating formatted strings.
The issue is that the following code returns a diagnostic error:
---@type string
local a = "%d %d" % {2, 3}
[{
"resource": "/home/nate/Documents/csdk/credo/crlua/libs/commands/slice.lua",
"owner": "_generated_diagnostic_collection_name_#6",
"code": "param-type-mismatch",
"severity": 4,
"message": "Cannot assign `number` to parameter `string`.",
"source": "Lua Diagnostics.",
"startLineNumber": 57,
"startColumn": 38,
"endLineNumber": 57,
"endColumn": 68
}]
It considers that the %
will return a number instead of a string.
This does make sense in general, but I see no way to override this feature in #499.