Skip to content

Commit 7baf2e0

Browse files
authored
Merge branch 'master' into 3357-string-match-returns
2 parents ca4bd21 + f3b91ad commit 7baf2e0

31 files changed

Lines changed: 704 additions & 384 deletions

.vscode/settings.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,11 @@
33
"Lua.misc.parameters": [
44
//"--preview",
55
"--develop=true",
6-
"--dbgport=11413",
6+
"--dbgport=11431",
7+
//"--dbgwait",
78
"--loglevel=trace",
9+
"--trace-rpc",
10+
//"--save-coder",
811
//"--shownode",
912
//"--lazy",
1013
],

changelog.md

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,34 @@
22

33
## Unreleased
44
<!-- Add all new changes here. They will be moved under a version at release -->
5-
* `CHG` Modified the `ResolveRequire` function to pass the source URI as a third argument.
5+
* `FIX` Correct `math.type` meta return annotation to use `nil` instead of the string literal `'nil'`
6+
* `FIX` Fix initial `nameStyle.config` not getting loaded in the appropriate workspace.
67
* `FIX` string.match and string.gmatch may return `string|integer?` [#3357](https://github.com/LuaLS/lua-language-server/issues/3357)
78

9+
## 3.18.2
10+
* `CHG` `duplicate-set-field` diagnostic now supports linked suppression: when any occurrence of a duplicate field is suppressed with `---@diagnostic disable` or `---@diagnostic disable-next-line`, all warnings for that field name will be suppressed
11+
* `REVERT` Reverted commit 1dd194da537df432f97295ea167dfef19acd7a4e which fix for type inference in and/or idioms. The circular dependency guard introduced issues with type narrowing in if-blocks where variables are reassigned (e.g., `if x then x = 0 end` would lose type information from the if-block in subsequent code). This needs a more refined solution to balance fixing circular dependencies without breaking type narrowing.
12+
13+
## 3.18.1
14+
`2026-04-08`
15+
* `FIX` Allow `global` to be used as an identifier in Lua 5.5 when it is not part of a `global` declaration
16+
17+
## 3.18.0
18+
`2026-04-03`
19+
* `CHG` Always track symbol-links
20+
* `CHG` Modified the `ResolveRequire` function to pass the source URI as a third argument.
21+
* `CHG` Improved the output of test failures during development
22+
* `FIX` Fix type inference for `x == nil and "default" or x` idiom [#2236](https://github.com/LuaLS/lua-language-server/issues/2236)
23+
* `FIX` Fix type loss for assignments inside `if`/`for` blocks due to circular dependency in tracer [#2374](https://github.com/LuaLS/lua-language-server/issues/2374) [#2494](https://github.com/LuaLS/lua-language-server/issues/2494)
24+
* `FIX` Resolve generic class method return types for `@param self list<T>` pattern
25+
* `FIX` Fix `ipairs(self)` type resolution in generic class methods
26+
* `FIX` Fix double angle brackets in generic sign display (`list<<T>>` -> `list<T>`)
27+
* `FIX` Fix nil crash in `getParentClass` for `doc.field` without class
28+
* `FIX` Fix type inference for bitwise operators (`<<`, `>>`, `&`, `|`, `~`) on integer variables
29+
* `FIX` Fix constant value computation for chained bitwise expressions in hover tooltips
30+
* `FIX` Support Lua 5.5 prefix local attributes such as `local <close>x` and `local <const>x`
31+
* `FIX` Correct `os` and `io` meta return types.
32+
833
## 3.17.1
934
`2026-01-20`
1035
* `FIX` Fixed a CPU usage issue again

meta/template/io.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ io = {}
2626

2727
---#DES 'io.close'
2828
---@param file? file*
29-
---@return boolean? suc
29+
---@return true? suc
3030
---@return exitcode? exitcode
3131
---@return integer? code
3232
function io.close(file) end
@@ -119,7 +119,7 @@ local file = {}
119119
---@alias exitcode "exit"|"signal"
120120

121121
---#DES 'file:close'
122-
---@return boolean? suc
122+
---@return true? suc
123123
---@return exitcode? exitcode
124124
---@return integer? code
125125
function file:close() end

meta/template/math.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ function math.tointeger(x) end
240240
---@return
241241
---| '"integer"'
242242
---| '"float"'
243-
---| 'nil'
243+
---| nil
244244
---@nodiscard
245245
function math.type(x) end
246246

meta/template/os.lua

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,23 +11,23 @@ function os.clock() end
1111

1212
---@class osdate:osdateparam
1313
---#DES 'osdate.year'
14-
---@field year integer|string
14+
---@field year integer
1515
---#DES 'osdate.month'
16-
---@field month integer|string
16+
---@field month integer
1717
---#DES 'osdate.day'
18-
---@field day integer|string
18+
---@field day integer
1919
---#DES 'osdate.hour'
20-
---@field hour integer|string
20+
---@field hour integer
2121
---#DES 'osdate.min'
22-
---@field min integer|string
22+
---@field min integer
2323
---#DES 'osdate.sec'
24-
---@field sec integer|string
24+
---@field sec integer
2525
---#DES 'osdate.wday'
26-
---@field wday integer|string
26+
---@field wday integer
2727
---#DES 'osdate.yday'
28-
---@field yday integer|string
28+
---@field yday integer
2929
---#DES 'osdate.isdst'
30-
---@field isdst boolean
30+
---@field isdst boolean?
3131

3232
---#DES 'os.date'
3333
---@param format? string
@@ -50,7 +50,7 @@ function os.difftime(t2, t1) end
5050
function os.execute(command) end
5151
---#else
5252
---@param command? string
53-
---@return boolean? suc
53+
---@return true? suc
5454
---@return exitcode? exitcode
5555
---@return integer? code
5656
function os.execute(command) end
@@ -75,15 +75,17 @@ function os.getenv(varname) end
7575

7676
---#DES 'os.remove'
7777
---@param filename string
78-
---@return boolean suc
78+
---@return true? suc
7979
---@return string? errmsg
80+
---@return integer? errcode
8081
function os.remove(filename) end
8182

8283
---#DES 'os.rename'
8384
---@param oldname string
8485
---@param newname string
85-
---@return boolean suc
86+
---@return true? suc
8687
---@return string? errmsg
88+
---@return integer? errcode
8789
function os.rename(oldname, newname) end
8890

8991
---@alias localecategory

script/core/diagnostics/duplicate-set-field.lua

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ local guide = require 'parser.guide'
44
local vm = require 'vm'
55
local await = require 'await'
66

7+
local DIAG_NAME = 'duplicate-set-field'
8+
79
local sourceTypes = {
810
'setfield',
911
'setmethod',
@@ -49,6 +51,7 @@ return function (uri, callback)
4951
end
5052
local myTopBlock = getTopFunctionOfIf(src)
5153
local defs = vm.getDefs(src)
54+
local validDefs = {}
5255
for _, def in ipairs(defs) do
5356
if def == src then
5457
goto CONTINUE
@@ -72,17 +75,27 @@ return function (uri, callback)
7275
-- allow type variable to override function defined in class variable
7376
goto CONTINUE
7477
end
75-
callback {
76-
start = src.start,
77-
finish = src.finish,
78-
related = {{
78+
if vm.isDiagDisabledAt(guide.getUri(def), def.start, DIAG_NAME) then
79+
return
80+
end
81+
validDefs[#validDefs+1] = def
82+
::CONTINUE::
83+
end
84+
if #validDefs > 0 then
85+
local related = {}
86+
for _, def in ipairs(validDefs) do
87+
related[#related + 1] = {
7988
start = def.start,
8089
finish = def.finish,
8190
uri = guide.getUri(def),
82-
}},
91+
}
92+
end
93+
callback {
94+
start = src.start,
95+
finish = src.finish,
96+
related = related,
8397
message = lang.script('DIAG_DUPLICATE_SET_FIELD', name),
8498
}
85-
::CONTINUE::
8699
end
87100
end)
88101
end

script/files.lua

Lines changed: 1 addition & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -80,39 +80,7 @@ end
8080
---@param uri uri
8181
---@return uri
8282
function m.getRealUri(uri)
83-
if platform.os ~= 'windows' then
84-
return furi.normalize(uri)
85-
end
86-
if not furi.isValid(uri) then
87-
return uri
88-
end
89-
local filename = furi.decode(uri)
90-
-- normalize uri
91-
uri = furi.encode(filename)
92-
local path = fs.path(filename)
93-
local suc, exists = pcall(fs.exists, path)
94-
if not suc or not exists then
95-
return uri
96-
end
97-
local suc, res = pcall(fs.canonical, path)
98-
if not suc then
99-
return uri
100-
end
101-
filename = res:string()
102-
local ruri = furi.encode(filename)
103-
if uri == ruri then
104-
return ruri
105-
end
106-
local real = getRealParent(path:parent_path()) / res:filename()
107-
ruri = furi.encode(real:string())
108-
if uri == ruri then
109-
return ruri
110-
end
111-
if not uriMap[uri] then
112-
uriMap[uri] = true
113-
log.warn(('Fix real file uri: %s -> %s'):format(uri, ruri))
114-
end
115-
return ruri
83+
return furi.normalize(uri)
11684
end
11785

11886
--- 打开文件

script/fs-utility.lua

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ function m.loadFile(path, keepBom)
2020
---@diagnostic disable-next-line: undefined-field
2121
path = path:string()
2222
end
23+
---@cast path string
2324
local f, e = ioOpen(path, 'rb')
2425
if not f then
2526
return nil, e

0 commit comments

Comments
 (0)