
Description
How are you using the lua-language-server?
Command Line
Which OS are you using?
Windows
What is the issue affecting?
Diagnostics/Syntax Checking
Expected Behaviour
For the same code and configuration, the diagnostics reported by the CLI match the diagnostics in VSCode.
Actual Behaviour
For the same code and configuration, the diagnostics reported by the CLI deviate from the diagnostics in VSCode.
Reproduction steps
- Create a workspace directory with some Lua files. In my example, I use two files
B.lua
andR.lua
. The content ofB.lua
is:
A = {}
A.B = {}
function A.f()
end
function A.B.g()
end
local function test()
m = require('R')
m.s()
G = 5 + 5
G = math.abs(G) + math.acos()
end
The content of R.lua
is:
local function s()
end
return { s }
- Open the workspace in VSCode and change some diagnostics levels in the settings. I changed the
groupSeverity
ofglobal
toError
and theseverity
ofmissing-parameter
toError
. VSCode shows the diagnostics as expected:
- Execute the
check
command with the CLI. I executed the commandC:\Users\<user name>\.vscode\extensions\sumneko.lua-3.6.11-win32-x64\server\bin\lua-language-server.exe --loglevel debug --logpath log --metapath meta --configpath C:\Development\git-repos\bug-report\diagnosis-report\settings.json --check C:\Development\git-repos\bug-report\diagnosis-report\library --checklevel Hint
(the current working directory is set toC:\Development\git-repos\bug-report\diagnosis-report
) with the following settings file content:
{
"file:///c%3A/Development/git-repos/bug-report/diagnosis-report/library/B.lua": [
{
"code": "undefined-global",
"message": "Undefined global `A`.",
"range": {
"end": {
"character": 1,
"line": 1
},
"start": {
"character": 0,
"line": 1
}
},
"severity": 1,
"source": "Lua Diagnostics."
},
{
"code": "undefined-global",
"message": "Undefined global `A`.",
"range": {
"end": {
"character": 10,
"line": 3
},
"start": {
"character": 9,
"line": 3
}
},
"severity": 1,
"source": "Lua Diagnostics."
},
{
"code": "undefined-global",
"message": "Undefined global `A`.",
"range": {
"end": {
"character": 10,
"line": 6
},
"start": {
"character": 9,
"line": 6
}
},
"severity": 1,
"source": "Lua Diagnostics."
},
{
"code": "undefined-global",
"message": "Undefined global `m`.",
"range": {
"end": {
"character": 5,
"line": 11
},
"start": {
"character": 4,
"line": 11
}
},
"severity": 1,
"source": "Lua Diagnostics."
},
{
"code": "undefined-global",
"message": "Undefined global `require`.(You can treat `require` as `require` by setting.)",
"range": {
"end": {
"character": 15,
"line": 10
},
"start": {
"character": 8,
"line": 10
}
},
"severity": 1,
"source": "Lua Diagnostics."
},
{
"code": "undefined-global",
"message": "Undefined global `math`.",
"range": {
"end": {
"character": 12,
"line": 13
},
"start": {
"character": 8,
"line": 13
}
},
"severity": 1,
"source": "Lua Diagnostics."
},
{
"code": "undefined-global",
"message": "Undefined global `G`.",
"range": {
"end": {
"character": 18,
"line": 13
},
"start": {
"character": 17,
"line": 13
}
},
"severity": 1,
"source": "Lua Diagnostics."
},
{
"code": "undefined-global",
"message": "Undefined global `math`.",
"range": {
"end": {
"character": 26,
"line": 13
},
"start": {
"character": 22,
"line": 13
}
},
"severity": 1,
"source": "Lua Diagnostics."
},
{
"code": "unused-function",
"message": "Unused functions.",
"range": {
"end": {
"character": 14,
"line": 9
},
"start": {
"character": 6,
"line": 9
}
},
"severity": 4,
"source": "Lua Diagnostics.",
"tags": [
1
]
},
{
"code": "unused-local",
"message": "Unused local `test`.",
"range": {
"end": {
"character": 19,
"line": 9
},
"start": {
"character": 15,
"line": 9
}
},
"severity": 4,
"source": "Lua Diagnostics.",
"tags": [
1
]
},
{
"code": "lowercase-global",
"message": "Global variable in lowercase initial, Did you miss `local` or misspell it?",
"range": {
"end": {
"character": 5,
"line": 10
},
"start": {
"character": 4,
"line": 10
}
},
"severity": 1,
"source": "Lua Diagnostics."
}
]
}
It is confusing that undefined globals are reported.
6. More confusingly, if I comment line 11 in B.lua
(m = require('R')
) out and execute the check command again, 99 problems are reported. Here is an incomplete list of the problems:
{
"file:///c%3A/Development/git-repos/bug-report/diagnosis-report/library/B.lua": [
{
"code": "undefined-global",
"message": "Undefined global `A`.",
"range": {
"end": {
"character": 1,
"line": 1
},
"start": {
"character": 0,
"line": 1
}
},
"severity": 1,
"source": "Lua Diagnostics."
},
{
"code": "undefined-global",
"message": "Undefined global `A`.",
"range": {
"end": {
"character": 10,
"line": 3
},
"start": {
"character": 9,
"line": 3
}
},
"severity": 1,
"source": "Lua Diagnostics."
},
{
"code": "undefined-global",
"message": "Undefined global `A`.",
"range": {
"end": {
"character": 10,
"line": 6
},
"start": {
"character": 9,
"line": 6
}
},
"severity": 1,
"source": "Lua Diagnostics."
},
{
"code": "undefined-global",
"message": "Undefined global `m`.",
"range": {
"end": {
"character": 5,
"line": 11
},
"start": {
"character": 4,
"line": 11
}
},
"severity": 1,
"source": "Lua Diagnostics."
},
{
"code": "undefined-global",
"message": "Undefined global `math`.",
"range": {
"end": {
"character": 12,
"line": 13
},
"start": {
"character": 8,
"line": 13
}
},
"severity": 1,
"source": "Lua Diagnostics."
},
{
"code": "undefined-global",
"message": "Undefined global `G`.",
"range": {
"end": {
"character": 18,
"line": 13
},
"start": {
"character": 17,
"line": 13
}
},
"severity": 1,
"source": "Lua Diagnostics."
},
{
"code": "undefined-global",
"message": "Undefined global `math`.",
"range": {
"end": {
"character": 26,
"line": 13
},
"start": {
"character": 22,
"line": 13
}
},
"severity": 1,
"source": "Lua Diagnostics."
},
{
"code": "unused-function",
"message": "Unused functions.",
"range": {
"end": {
"character": 14,
"line": 9
},
"start": {
"character": 6,
"line": 9
}
},
"severity": 4,
"source": "Lua Diagnostics.",
"tags": [
1
]
},
{
"code": "unused-local",
"message": "Unused local `test`.",
"range": {
"end": {
"character": 19,
"line": 9
},
"start": {
"character": 15,
"line": 9
}
},
"severity": 4,
"source": "Lua Diagnostics.",
"tags": [
1
]
},
{
"code": "undefined-global",
"message": "Undefined global `A`.",
"range": {
"end": {
"character": 1,
"line": 1
},
"start": {
"character": 0,
"line": 1
}
},
"severity": 1,
"source": "Lua Diagnostics."
},
{
"code": "undefined-global",
"message": "Undefined global `A`.",
"range": {
"end": {
"character": 10,
"line": 3
},
"start": {
"character": 9,
"line": 3
}
},
"severity": 1,
"source": "Lua Diagnostics."
},
{
"code": "undefined-global",
"message": "Undefined global `A`.",
"range": {
"end": {
"character": 10,
"line": 6
},
"start": {
"character": 9,
"line": 6
}
},
"severity": 1,
"source": "Lua Diagnostics."
},
{
"code": "undefined-global",
"message": "Undefined global `m`.",
"range": {
"end": {
"character": 5,
"line": 11
},
"start": {
"character": 4,
"line": 11
}
},
"severity": 1,
"source": "Lua Diagnostics."
},
{
"code": "undefined-global",
"message": "Undefined global `math`.",
"range": {
"end": {
"character": 12,
"line": 13
},
"start": {
"character": 8,
"line": 13
}
},
"severity": 1,
"source": "Lua Diagnostics."
},
{
"code": "undefined-global",
"message": "Undefined global `G`.",
"range": {
"end": {
"character": 18,
"line": 13
},
"start": {
"character": 17,
"line": 13
}
},
"severity": 1,
"source": "Lua Diagnostics."
},
{
"code": "undefined-global",
"message": "Undefined global `math`.",
"range": {
"end": {
"character": 26,
"line": 13
},
"start": {
"character": 22,
"line": 13
}
},
"severity": 1,
"source": "Lua Diagnostics."
}
],
"file:///c%3A/Development/git-repos/bug-report/diagnosis-report/meta/Lua%205.4%20en-us%20utf8/basic.lua": [
<further diagnostics>
],
"file:///c%3A/Development/git-repos/bug-report/diagnosis-report/meta/Lua%205.4%20en-us%20utf8/builtin.lua": [
{
"code": "undefined-doc-class",
"message": "Undefined class `stringlib`.",
"range": {
"end": {
"character": 27,
"line": 12
},
"start": {
"character": 18,
"line": 12
}
},
"relatedInformation": [],
"severity": 2,
"source": "Lua Diagnostics."
}
]
}
Additional Notes
I am not sure if I am using the CLI correctly. I oriented me on the wiki page about the diagnosis report and CLI flags. So, if this is not a bug, I am sorry and you can close this issue.
Log File
This is the log file for the first run:
file_c%3A_Development_git-repos_bug-report_diagnosis-report_library.log
This is the log file for the second run (with line 11 commented out):
file_c%3A_Development_git-repos_bug-report_diagnosis-report_library.log