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

EmmyLua: Undefined field warning for generics #531

Closed
Ketho opened this issue May 8, 2021 · 1 comment
Closed

EmmyLua: Undefined field warning for generics #531

Ketho opened this issue May 8, 2021 · 1 comment
Labels
bug Something isn't working feat/LuaCats Annotations Related to Lua Language Server Annotations (LuaCats)

Comments

@Ketho
Copy link

Ketho commented May 8, 2021

Describe the bug
When accessing a field on an object returned by generics, it gives an undefined field warning even if it's actually defined.

To Reproduce

---@class Frame
---@field isFrame boolean
local Frame = {}

---@generic T
---@param name `T`
---@return T
function Generic(name) end

local foo = Generic("Frame")
foo.bar = 123
print(foo.bar)

image

Expected behavior
For the warning not to appear.

Environment:

  • OS: Windows 10
  • sumneko.lua 1.21.1
  • VSCode 1.56.0

Additional context
Manually annotating it seems to be a workaround.

---@type Frame
local foo = Generic("Frame")
foo.bar = 123
print(foo.bar)
@Ketho Ketho changed the title EmmyLua: Undefined field warning for Generics EmmyLua: Undefined field warning for generics May 10, 2021
@sumneko sumneko added bug Something isn't working feat/LuaCats Annotations Related to Lua Language Server Annotations (LuaCats) labels May 11, 2021
@Ketho
Copy link
Author

Ketho commented Jun 21, 2021

Thank you ❤️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working feat/LuaCats Annotations Related to Lua Language Server Annotations (LuaCats)
Projects
None yet
Development

No branches or pull requests

2 participants