LuaLS / LuaLS/lua-language-server
duplicate field error when setting a field to a function in an if/else
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
No duplicate field error
### Actual Behaviour

``` local t = {}
if x then
t.s = function() return 1 end
else
t.s = function() return 2 end
end
```
This is not a duplicate field and should not be an error
### Reproduction steps
``` local t = {}
if x then
t.s = function() return 1 end
else
t.s = function() return 2 end
end
```
Write that into the editor. See error as indicated above.
### Additional Notes
v3.6.4
### Log File
[file_c%3A_Users_User_AppData_Roaming_Factorio_mods_space-exploration.log](https://github.com/sumneko/lua-language-server/files/10316714/file_c.3A_Users_User_AppData_Roaming_Factorio_mods_space-exploration.log)
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the diagnostic in the Visual Studio Code extension using the provided conditional-assignment snippet, focusing on the Diagnostics/Syntax Checking entry point. Trace why the two branch assignments are reported as a duplicate field, then verify that the same example no longer produces the error.
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
- Clearly specified
- Newbie friendliness
- 45/100