Skip to content

assert() "Cannot assign unknown to parameter <T>?." #1306

Closed
@flrgh

Description

@flrgh

version 3.4.2

Describe the bug

I believe this is a general issue, but I'll describe it as it pertains to assert, since that is a concrete example.

To Reproduce

local value
assert(value, "assertion failed")

This yields a diagnostic warning:

Cannot assign unknown to parameter <T>?

Expected behavior

This seems unexpected to me, since a generic type param (<T>) should theoretically accept any type, especially since the parameter is optional. Is it a bug or expected behavior?

I'd prefer not to disable this diagnostic, because it is helpful in other cases where there is a real type mismatch.


lua-language-server.log
neovim-lsp.log
Screenshot from 2022-07-14 11-44-17

Screenshot from 2022-07-14 11-55-01

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions