Skip to content
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

duplicate field error when setting a field to a function in an if/else #1794

Open
BurninSun opened this issue Dec 28, 2022 · 2 comments
Open
Labels
enhancement New feature or request
Milestone

Comments

@BurninSun
Copy link

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

image

  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

  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

@BribeFromTheHive
Copy link

Can confirm. Had to build out your example a bit, but the error message does indeed occur:

  local t = {}
  local x = true
  if x then
    t.s = function() return 1 end
  else
    t.s = function() return 2 end
  end

@jdahlblom
Copy link

jdahlblom commented Sep 13, 2023

Also using VS Code (1.82.1) & the sumneko (v3.7.0) extension on Windows 11.
I have a @meta file with definitions for external APIs.
Is this the same problem?
I currently have the the inspection disabled by adding this before each @field that is flagged as duplicate:
--- @diagnostic disable-next-line: duplicate-doc-field

2023-09-13_092731
2023-09-13_092717

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants