Skip to content

Issue with generic parameters in 3.6 #1676

@firas-assaad

Description

@firas-assaad

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?

Annotations, Type Checking, Diagnostics/Syntax Checking

Expected Behaviour

image

Actual Behaviour

image

Reproduction steps

---@generic T
---@param arr T[]
---@param val? T|(fun(e : T) : boolean)
---@return T? element
local function find(arr, val)
    return arr[1]
end

local arr = { 'a', 'b' }
find(arr, 'b')

Additional Notes

Not sure if my annotations are wrong, but it worked in the previous version. If I change the signature so that the second parameter is T instead of T|fun(e : T) : boolean then it works fine.

---@generic T
---@param arr T[]
---@param val? T
---@return T? element
local function find(arr, val)

Thanks for your continued work on the language server!

Log File

Let me know if you need it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingfeat/genericRelated to generic emulation featurefeat/type checkRelated to the type checking feature

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions