Skip to content

[Enhancement] Improve fun type matching #2965

Open
@d-enk

Description

@d-enk
---@class Class
---@field f fun(s: string): integer

---@param f fun(x: string): integer
local function handle(f)
	return f("string")
end

-----

---@param i number
---@return boolean
local function is_positive(i)
	return i >= 0
end

handle(is_positive) -- expect `param-type-mismatch`

---@type Class
local _ = { f = is_positive } -- expect `assign-type-mismatch`

Expected warning:
Type fun(i: number):boolean cannot match fun(x: string):integer

I didn't find duplicates, although I expected them
maybe I didn't search well

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