Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

enum bug #1370

Closed
RomanSpector opened this issue Jul 22, 2022 · 2 comments
Closed

enum bug #1370

RomanSpector opened this issue Jul 22, 2022 · 2 comments
Labels
enhancement New feature or request

Comments

@RomanSpector
Copy link

Works here:

image

And it doesn't work here anymore:
image

---@enum animal
Animal = {
  Cat = 1,
  Dog = 2,
}

---@param x animal
local function f(x) end

f(Animal.Cat) -- suggests `Animal.Cat`, `Animal.Dog`, `1`, `2` as the first parameter

---@enum flags
Flags =
{
    FLAG_1 = 0x00000000,
    FLAG_2 = 0x00000001,
    FLAG_3 = 0x00000002,
    FLAG_4 = 0x00000004,
    FLAG_5 = 0x00000008,
}

---@param flag flags
local function SetCharmInfoFlags(flag) end

SetCharmInfoFlags(Flags.FLAG_3);
@sumneko sumneko added the bug Something isn't working label Jul 22, 2022
@sumneko
Copy link
Collaborator

sumneko commented Jul 25, 2022

---@enum is binded to the table instead of variable, so the brackets cannot start another line.

This is to achieve:

local function getEnums()
    ---@enum X
    return {
        x = 1,
        y = 2,
        z = 3,
    }
end

@sumneko sumneko added enhancement New feature or request and removed bug Something isn't working labels Jul 25, 2022
@sumneko
Copy link
Collaborator

sumneko commented Jul 25, 2022

I find a easy way to achieve the both case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants