Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 996e21a

Browse files
authored
Merge pull request #3251 from f-ell/fix/signature-tuple-parameters
fix: incorrect generation of function signatures with tuple parameters
2 parents 9ffeeef + b1a3f3e commit 996e21a

File tree

3 files changed

+39
-1
lines changed

3 files changed

+39
-1
lines changed

‎changelog.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
## Unreleased
44
<!-- Add all new changes here. They will be moved under a version at release -->
5+
* `FIX` Incorrect generation of function signatures with tuple-parameters
56
* `NEW` Doc output now contains file paths for `@alias` and `@enum` types
67
* `FIX` Typos in a few error messages.
78
* `FIX` Incorrect inject-field message for extra table field in exact class

‎script/core/signature.lua‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,11 @@ local function makeOneSignature(source, oop, index)
6363
: gsub('%b{}', function (str)
6464
return ('_'):rep(#str)
6565
end)
66-
: gsub('[%[%]%(%)]', '_')
66+
: gsub ('%b[]', function (str)
67+
return ('_'):rep(#str)
68+
end)
69+
: gsub('[%(%)]', '_')
70+
6771
for start, finish in converted:gmatch '%s*()[^,]+()' do
6872
i = i + 1
6973
params[i] = {

‎test/signature/init.lua‎

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,39 @@ end)(<??>)
234234
]]
235235
{'function (<!a: any!>, b: any)'}
236236

237+
TEST [[
238+
---@param a [any, any]
239+
---@param b any
240+
function X(a, b) end
241+
242+
X({ 1, 2 }, <?3?>)
243+
]]
244+
{
245+
'function X(a: [any, any], <!b: any!>)'
246+
}
247+
248+
TEST [[
249+
---@param a any
250+
---@param b [any, any]
251+
---@param c any
252+
function X(a, b, c) end
253+
254+
X(1, { 2, 3 }<??>, 4)
255+
]]
256+
{
257+
'function X(a: any, <!b: [any, any]!>, c: any)'
258+
}
259+
260+
TEST [[
261+
---@param a [table<any>, {[1]:any,[2]:any}]
262+
function X(a) end
263+
264+
X({ { 1 }, { 2, 3 } }<??>)
265+
]]
266+
{
267+
'function X(<!a: [table<any>, { [1]: any, [2]: any }]!>)'
268+
}
269+
237270
TEST [[
238271
---@overload fun()
239272
---@overload fun(a:number)

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /