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

table validation is not working as expected #3040

Open
kuxynator opened this issue Jan 13, 2025 · 1 comment
Open

table validation is not working as expected #3040

kuxynator opened this issue Jan 13, 2025 · 1 comment

Comments

@kuxynator
Copy link

kuxynator commented Jan 13, 2025

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?

Type Checking

Expected Behaviour

"inject-field" or "undefined-field" should show an error in table definition

Actual Behaviour

	"Lua.diagnostics.severity": {
		"inject-field": "Error",
		"undefined-field": "Error"
		"missing-fields": "Error"  // <-this works
	},
	---@type Foo
	local entity = {  --  <--expected error "bar  is missing"
		here_should_be_an_error ="but is not"
	}
	
	---@class (exact) Foo
	---@field bar string

Reproduction steps

  1. Go to '...'
  2. Click '...'
  3. See error '...'

Additional Notes

No response

Log File

No response

@tomlau10
Copy link
Contributor

tomlau10 commented Jan 14, 2025

Seems duplicated as the following issues:


Meanwhile, I think the undefined-field check is unrelated here. 🤔
It is for checking if the code tries to index an undefined field:

	---@type Foo
	local entity = {  --  <--expected error "bar  is missing"
	}
	print(entity.x) --> Undefined field `x`.
	
	---@class (exact) Foo
	---@field bar string

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

No branches or pull requests

2 participants