From 0d34be593cd46285927f9f0daefd5a4d78faee29 Mon Sep 17 00:00:00 2001 From: Nico Pareigis Date: Thu, 14 Aug 2025 16:54:08 +0200 Subject: [PATCH 1/3] fix(signature): prevent tuple parameters from being split up --- script/core/signature.lua | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/script/core/signature.lua b/script/core/signature.lua index 3f32bd3f7..1c3ba76b8 100644 --- a/script/core/signature.lua +++ b/script/core/signature.lua @@ -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] = { From 90bad47c565509800d22ce6fc54a05f2e7e4178c Mon Sep 17 00:00:00 2001 From: Nico Pareigis Date: Thu, 14 Aug 2025 17:37:10 +0200 Subject: [PATCH 2/3] test(signature): add tests for functions with tuple parameters --- test/signature/init.lua | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/test/signature/init.lua b/test/signature/init.lua index 010c15314..3423a03ec 100644 --- a/test/signature/init.lua +++ b/test/signature/init.lua @@ -234,6 +234,39 @@ end)() ]] {'function (, b: any)'} +TEST [[ +---@param a [any, any] +---@param b any +function X(a, b) end + +X({ 1, 2 }, ) +]] +{ +'function X(a: [any, 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, , c: any)' +} + +TEST [[ +---@param a [table, {[1]:any,[2]:any}] +function X(a) end + +X({ { 1 }, { 2, 3 } }) +]] +{ +'function X(, { [1]: any, [2]: any }]!>)' +} + TEST [[ ---@overload fun() ---@overload fun(a:number) From f2152a48b64f9c35766fd4f36c08c5f9ccc83374 Mon Sep 17 00:00:00 2001 From: Nico Pareigis Date: Thu, 14 Aug 2025 18:16:03 +0200 Subject: [PATCH 3/3] doc: update changelog --- changelog.md | 1 + 1 file changed, 1 insertion(+) diff --git a/changelog.md b/changelog.md index 59d4dee24..b46eb936b 100644 --- a/changelog.md +++ b/changelog.md @@ -2,6 +2,7 @@ ## Unreleased +* `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.