-
-
Notifications
You must be signed in to change notification settings - Fork 391
duplicate-index and duplicate-set-field change to disabled by default
#3038
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
duplicate-index and duplicate-set-field change to disabled byduplicate-index and duplicate-set-field change to disabled by default
|
Information is a diagnostic just like warning. |
Okay, I change the severity back into warning. |
|
I think you just don't understand how luals works... I know that you don't agree with it and don't want to use
In your very beginning example without any annotation in #3035 local Object = {}
local Animal = Object
function Animal:Speak()
print('Animal.Speak')
end
local Person = Animal
function Person:Speak() --- warning duplicate-set-field
print('Person.Speak')
end
local p1 = Person
p1:Speak() --> (method) Animal:Speak(); wrong hover info !!!I don't know what's your implementation of
And then I think you will open another issue reporting this ("incorrect" hover). And once you added proper On the other hand, turning the diagnostic to be disabled by default will affect all users:
Please note that I am no maintainer, and I cannot represent maintainers's view. |
Please check out this kind of code: --- @generic T
--- @param class T
--- @return T
local function New( class )
return setmetatable({}, {__index = class})
end
local Animal = {}
function Animal:Speak()
print('Animal:Speak')
end
local Person = New(Animal)
--- Lua Diagnostics: Duplicate field `Speak`
function Person:Speak()
print('Person:Speak')
end
Person:Speak() -- print Person:Speak
local someone = New(Person)
someone:Speak() -- print Person:SpeakThe LuaLS linter can't do correly scanning the case table not mark with a I stand for disabling it defaultly and it can rollbacks to enable when LuaLS AST scanner become stronger and solve the defect of this case in the future. Enforcing rules is kinda the point of a linter innit. We should stop it if linter works incorrect or having defects.. |
|
The main reason for these issues is that luals lacks a way to treat the variable that holds the return value as a new anonymous type that automatically inherits from the return type. This results in the need to write many classes, which is quite reasonable and common in Lua itself. These two diagnostics themselves are also fine; it is indeed unreasonable to repeatedly declare in the same class. In summary, the Lua LS type and inference system are not mature enough, and the lint does not match the current inference capabilities, which are overly advanced. |
This is reason and truth I wanna tell. Thanks to @CppCXY!!! |
|
我不同意将其默认禁用,理由如下:
因此我认为让用户自己选择“TRUST ME”比什么都不做要更好。 |
I don't agree with it being disabled by default for the following reasons:
So I think it's better to let users choose "TRUST ME" than to do nothing. |
行,那等你的 bugfix,我这边先关闭了 |
Okay, let me wait for your bugfix. I will close it here first. |


In order to left and keep Lua as Lua.
The relative issue was talked in #3035 and #3039 (comment).