Skip to content

Table literals aren't properly checked for field injections and missing fields #2802

@Calandiel

Description

@Calandiel

How are you using the lua-language-server?

Visual Studio Code Extension (sumneko.lua)

Which OS are you using?

Linux

What is the issue affecting?

Type Checking

Expected Behaviour

I'd expect tables created in the return statement to check for missing fields, and those created outside of them to check for injected fields.

Actual Behaviour

There are no warnings emitted for the attached code.

Reproduction steps

Code to reproduce the issue:

---@class Tile
---@field name string

local Tile = {}

---@return Tile
function Tile.new()
	---@type Tile
	local d = {
		name = 'abc',
		f = 10 -- No warning when a field is being injected
	}

	return {
		f = 10 -- No warning even though there's a missing field and a field is being injected
	}
end

Note that it won't produce any warnings, regardless of configuration (as far as I can tell).

Additional Notes

No response

Log File

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions