Skip to content

Enum created with @alias breaks when unioned with table #3141

@Lexicality

Description

@Lexicality

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

it should allow either the enum or a table

Actual Behaviour

Cannot assign `integer` to parameter ``BAR`|`FOO`|any[]`.
- `integer` cannot match ``BAR`|`FOO`|any[]`
- Type `integer` cannot match `any[]`
- Type `number` cannot match `any[]`

Reproduction steps

FOO = 1
BAR = 2

--- @alias WAT `FOO` | `BAR`
--- @param a WAT | any[]
local function aa(a) end

aa(FOO)

Additional Notes

Bonus: If you change the type to WAT | WAT[] the error message is

Cannot assign `integer` to parameter ``BAR`|`BAR`|`FOO`[]|`FOO``.
- `integer` cannot match ``BAR`|`BAR`|`FOO`[]|`FOO``
- Type `integer` cannot match ``BAR`|`FOO`[]`
- Type `number` cannot match ``BAR`|`FOO`[]`

which looks very visually confusing

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