LuaLS / LuaLS/lua-language-server

Override is prevented from linter

Open
#3,039 30 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Lua
Stars
4.4k
Forks
442
PR merge metrics
No merged PRs in 30d

Description

How are you using the lua-language-server?

Visual Studio Code Extension (sumneko.lua)

Which OS are you using?

Windows

What is the issue affecting?

Diagnostics/Syntax Checking

Expected Behaviour
local a = {}
a.__index = a
function a:m1()
end

-- b inherit from a
local b = setmetatable({}, a)
-- override m2()
function b:m2() --- no warning generated
end
Actual Behaviour
local a = {}
a.__index = a
function a:m1()
end

-- b inherit from a
local b = setmetatable({}, a)
-- override m2()
function b:m2() --- duplicate field `m`
end

image

Reproduction steps
  1. Just copy the code and lint them
Additional Notes

Inheritance and override methods is prevent by LuaLS linter.

Override is a common and basic concept. But LuaLS seems can't recognize it but provide warnings.

In the case, m2 is not a duplicate field, but just shadowing or overriding.

Log File

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the diagnostic in the Visual Studio Code Extension using the Lua snippet under Diagnostics/Syntax Checking. Then trace the linter’s duplicate-field diagnostic and its handling of setmetatable inheritance; done means m2 is not reported as a duplicate while unrelated duplicate fields still are.

Written by the indexing model from the issue text.

Assessment

Tech stack
lua
Domain
devtools
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.