Skip to content

Commit 5534451

Browse files
authored
Merge branch 'master' into correct-pattern-links
2 parents dec7f3b + 1d5aee3 commit 5534451

File tree

7 files changed

+218
-19
lines changed

7 files changed

+218
-19
lines changed

changelog.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,16 @@
22

33
## Unreleased
44
<!-- Add all new changes here. They will be moved under a version at release -->
5-
* `FIX` incorrect argument skip pattern for `--check_out_path=`, which incorrectly skips the next argument
5+
* `NEW` CLI: added `--help`.
66
* `CHG` default path for `--doc_out_path` is the current directory
7+
* `FIX` incorrect argument skip pattern for `--check_out_path=`, which incorrectly skips the next argument
78
* `FIX` incorrect error message for `--doc_update`.
89
* `FIX` reimplement section `luals.config` in file doc.json
910
* `FIX` incorrect file names in file doc.json
1011
* `FIX` remove extra `./` path prefix in the check report when using `--check=.`
1112
* `FIX` incorrect links for `pattern` in `string` methods
13+
* `FIX` fix type annotations for bit module
14+
* `FIX` Another regression related to type narrow and generic param introduced since `v3.10.1` [#3087](https://github.com/LuaLS/lua-language-server/issues/3087)
1215

1316
## 3.13.6
1417
`2025-2-6`

meta/template/bit.lua

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,25 +22,22 @@ function bit.tohex(x, n) end
2222
function bit.bnot(x) end
2323

2424
---@param x integer
25-
---@param x2 integer
2625
---@param ... integer
2726
---@return integer y
2827
---@nodiscard
29-
function bit.bor(x, x2, ...) end
28+
function bit.bor(x, ...) end
3029

3130
---@param x integer
32-
---@param x2 integer
3331
---@param ... integer
3432
---@return integer y
3533
---@nodiscard
36-
function bit.band(x, x2, ...) end
34+
function bit.band(x, ...) end
3735

3836
---@param x integer
39-
---@param x2 integer
4037
---@param ... integer
4138
---@return integer y
4239
---@nodiscard
43-
function bit.bxor(x, x2, ...) end
40+
function bit.bxor(x, ...) end
4441

4542
---@param x integer
4643
---@param n integer

script/cli/help.lua

Lines changed: 161 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,161 @@
1+
local util = require 'utility'
2+
3+
--- @class cli.arg
4+
--- @field type? string|string[]
5+
--- @field description string Description of the argument in markdown format.
6+
--- @field example? string
7+
--- @field default? any
8+
9+
--- @type table<string, cli.arg>
10+
local args = {
11+
['--help'] = {
12+
description = [[
13+
Print this message.
14+
]],
15+
},
16+
['--check'] = {
17+
type = 'string',
18+
description = [[
19+
Perform a "diagnosis report" where the results of the diagnosis are written to the logpath.
20+
]],
21+
example = [[--check=C:\Users\Me\path\to\workspace]]
22+
},
23+
['--checklevel'] = {
24+
type = 'string',
25+
description = [[
26+
To be used with --check. The minimum level of diagnostic that should be logged.
27+
Items with lower priority than the one listed here will not be written to the file.
28+
Options include, in order of priority:
29+
30+
- Error
31+
- Warning
32+
- Information
33+
- Hint
34+
]],
35+
default = 'Warning',
36+
example = [[--checklevel=Information]]
37+
},
38+
['--check_format'] = {
39+
type = { 'json', 'pretty' },
40+
description = [[
41+
Output format for the check results.
42+
- 'pretty': results are displayed to stdout in a human-readable format.
43+
- 'json': results are written to a file in JSON format. See --check_out_path
44+
]],
45+
default = 'pretty'
46+
},
47+
['--version'] = {
48+
type = 'boolean',
49+
description = [[
50+
Get the version of the Lua language server.
51+
This will print it to the command line and immediately exit.
52+
]],
53+
},
54+
['--doc'] = {
55+
type = 'string',
56+
description = [[
57+
Generate documentation from a workspace.
58+
The files will be output in your log path.
59+
]],
60+
example = [[--doc=C:/Users/Me/Documents/myLuaProject/]]
61+
},
62+
['--doc_out_path'] = {
63+
type = 'string',
64+
description = [[
65+
The path to output generated documentation at.
66+
See --doc for more info.
67+
]],
68+
example = [[--doc_out_path=C:/Users/Me/Documents/myLuaProjectDocumentation]]
69+
},
70+
['--logpath'] = {
71+
type = 'string',
72+
description = [[
73+
Where the log should be written to.
74+
]],
75+
default = './log',
76+
example = [[--logpath=D:/luaServer/logs]]
77+
},
78+
['--loglevel'] = {
79+
type = 'string',
80+
description = [[
81+
The minimum level of logging that should appear in the logfile.
82+
Can be used to log more detailed info for debugging and error reporting.
83+
84+
Options:
85+
86+
- error
87+
- warn
88+
- info
89+
- debug
90+
- trace
91+
]],
92+
example = [[--loglevel=trace]]
93+
},
94+
['--metapath'] = {
95+
type = 'string',
96+
description = [[
97+
Where the standard Lua library definition files should be generated to.
98+
]],
99+
default = './meta',
100+
example = [[--metapath=D:/sumnekoLua/metaDefintions]]
101+
},
102+
['--locale'] = {
103+
type = 'string',
104+
description = [[
105+
The language to use. Defaults to en-us.
106+
Options can be found in locale/ .
107+
]],
108+
example = [[--locale=zh-cn]]
109+
},
110+
['--configpath'] = {
111+
type = 'string',
112+
description = [[
113+
The location of the configuration file that will be loaded.
114+
Can be relative to the workspace.
115+
When provided, config files from elsewhere (such as from VS Code) will no longer be loaded.
116+
]],
117+
example = [[--configpath=sumnekoLuaConfig.lua]]
118+
},
119+
['--force-accept-workspace'] = {
120+
type = 'boolean',
121+
description = [[
122+
Allows the use of root/home directory as the workspace.
123+
]]
124+
},
125+
['--socket'] = {
126+
type = 'number',
127+
description = [[
128+
Will communicate to a client over the specified TCP port instead of through stdio.
129+
]],
130+
example = [[--socket=5050]]
131+
},
132+
['--develop'] = {
133+
type = 'boolean',
134+
description = [[
135+
Enables development mode. This allows plugins to write to the logpath.
136+
]]
137+
}
138+
}
139+
140+
for nm, attrs in util.sortPairs(args) do
141+
if attrs.type == 'boolean' then
142+
print(nm)
143+
else
144+
print(nm .. "=<value>")
145+
end
146+
if attrs.description then
147+
local normalized_description = attrs.description:gsub("^%s+", ""):gsub("\n%s+", "\n"):gsub("%s+$", "")
148+
print("\n " .. normalized_description:gsub('\n', '\n '))
149+
end
150+
local attr_type = attrs.type
151+
if type(attr_type) == "table" then
152+
print("\n Values: " .. table.concat(attr_type, ', '))
153+
end
154+
if attrs.default then
155+
print("\n Default: " .. tostring(attrs.default))
156+
end
157+
if attrs.example then
158+
print("\n Example: " .. attrs.example)
159+
end
160+
print()
161+
end

script/cli/init.lua

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
if _G['HELP'] then
2+
require 'cli.help'
3+
os.exit(0, true)
4+
end
5+
16
if _G['VERSION'] then
27
require 'cli.version'
38
os.exit(0, true)

script/global.d.lua

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,3 +109,5 @@ THREAD_ID = 1
109109
CHECK_WORKER = ''
110110

111111
QUIET = false
112+
113+
HELP = false

script/vm/compiler.lua

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -641,20 +641,11 @@ local function matchCall(source)
641641
newNode.originNode = myNode
642642
vm.setNode(source, newNode, true)
643643
if call.args then
644-
-- clear existing node caches of args to allow recomputation with the type narrowed call
644+
-- recompile existing node caches of args to allow recomputation with the type narrowed call
645645
for _, arg in ipairs(call.args) do
646646
if vm.getNode(arg) then
647-
vm.setNode(arg, vm.createNode(), true)
648-
end
649-
end
650-
for n in newNode:eachObject() do
651-
if n.type == 'function'
652-
or n.type == 'doc.type.function' then
653-
for i, arg in ipairs(call.args) do
654-
if vm.getNode(arg) and n.args[i] then
655-
vm.setNode(arg, vm.compileNode(n.args[i]))
656-
end
657-
end
647+
vm.removeNode(arg)
648+
vm.compileNode(arg)
658649
end
659650
end
660651
end

test/type_inference/common.lua

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4718,6 +4718,46 @@ local function f(v) end
47184718
local <?r?> = f('')
47194719
]]
47204720

4721+
TEST 'A' [[
4722+
---@class A
4723+
local A = {}
4724+
4725+
---@generic T
4726+
---@param self T
4727+
---@param s string
4728+
---@return T
4729+
function A:f(s) end
4730+
4731+
---@generic T
4732+
---@param self T
4733+
---@param i integer
4734+
---@return T
4735+
function A:f(i) end
4736+
4737+
local <?r?> = A:f('')
4738+
]]
4739+
4740+
TEST 'B' [[
4741+
---@class A
4742+
local A = {}
4743+
4744+
---@generic T
4745+
---@param self T
4746+
---@param s string
4747+
---@return T
4748+
function A:f(s) end
4749+
4750+
---@generic T
4751+
---@param self T
4752+
---@param i integer
4753+
---@return T
4754+
function A:f(i) end
4755+
4756+
---@class B: A
4757+
local B = {}
4758+
local <?r?> = B:f('')
4759+
]]
4760+
47214761
TEST 'integer' [[
47224762
local function F(...)
47234763
local t = {...}

0 commit comments

Comments
 (0)