Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

## Unreleased
<!-- Add all new changes here. They will be moved under a version at release -->
* `FIX` Incorrect generation of function signatures with tuple-parameters
* `FIX` Incorrect inject-field message for extra table field in exact class
* `CHG` Rename configuration option `Lua.diagnostics.disableScheme` to `Lua.diagnostics.validScheme` and improve its description. Now it enables diagnostics for Lua files that use the specified scheme.
* `FIX` adds the `|lambda|` operator to the `Lua.runtime.nonstandardSymbol` configuration template, which allows the use of that option. Previously, support for it existed in the parser, but we could not actually use the option because it is not recognised in the configuration.
Expand Down
6 changes: 5 additions & 1 deletion script/core/signature.lua
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,11 @@ local function makeOneSignature(source, oop, index)
: gsub('%b{}', function (str)
return ('_'):rep(#str)
end)
: gsub('[%[%]%(%)]', '_')
: gsub ('%b[]', function (str)
return ('_'):rep(#str)
end)
: gsub('[%(%)]', '_')

for start, finish in converted:gmatch '%s*()[^,]+()' do
i = i + 1
params[i] = {
Expand Down
33 changes: 33 additions & 0 deletions test/signature/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,39 @@ end)(<??>)
]]
{'function (<!a: any!>, b: any)'}

TEST [[
---@param a [any, any]
---@param b any
function X(a, b) end

X({ 1, 2 }, <?3?>)
]]
{
'function X(a: [any, any], <!b: any!>)'
}

TEST [[
---@param a any
---@param b [any, any]
---@param c any
function X(a, b, c) end

X(1, { 2, 3 }<??>, 4)
]]
{
'function X(a: any, <!b: [any, any]!>, c: any)'
}

TEST [[
---@param a [table<any>, {[1]:any,[2]:any}]
function X(a) end

X({ { 1 }, { 2, 3 } }<??>)
]]
{
'function X(<!a: [table<any>, { [1]: any, [2]: any }]!>)'
}

TEST [[
---@overload fun()
---@overload fun(a:number)
Expand Down
Loading