Skip to content

EmmyLua definitions not recognized in Lua Language Server v2.4.10 #822

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

Closed
Feez opened this issue Nov 24, 2021 · 5 comments
Closed

EmmyLua definitions not recognized in Lua Language Server v2.4.10 #822

Feez opened this issue Nov 24, 2021 · 5 comments
Labels
as designed Functioning as intended, will not be modified

Comments

@Feez
Copy link

Feez commented Nov 24, 2021

Describe the bug
EmmyLua declarations are not recognized anymore

This has only started occurring on version 2.4.10. Works otherwise on 2.4.9 and below.

To Reproduce
Steps to reproduce the behavior:

v2.4.9:
image

v2.4.10:
image

main.lua:

local definitions = require("definitions")

---@type MyType
local a

a:GetSomething()

definitions.lua:

local MyTypeTbl = {}

---@class MyType
function MyTypeTbl:init()
end

function MyTypeTbl:GetSomething()
    return 1
end

return {
    MyTypeTbl = MyTypeTbl
}

Expected behavior
Language server recognizes the EmmyLua type and the functions defined on it.

Environment (please complete the following information):
Version: 1.62.3 (system setup)
Commit: ccbaa2d27e38e5afa3e5c21c1c7bef4657064247
Date: 2021-11-17T08:11:14.551Z
Electron: 13.5.2
Chrome: 91.0.4472.164
Node.js: 14.16.0
V8: 9.1.269.39-electron.0
OS: Windows_NT x64 10.0.19042

(Not remote)

Provide logs
Not sure if applicable, but log - https://pastebin.com/raw/29uYg7jN

@sumneko
Copy link
Collaborator

sumneko commented Nov 25, 2021

Should be

---@class MyType
local MyTypeTbl = {}

function MyTypeTbl:init()
end

function MyTypeTbl:GetSomething()
    return 1
end

return {
    MyTypeTbl = MyTypeTbl
}

Related to: #806

@Feez
Copy link
Author

Feez commented Nov 25, 2021

@sumneko Still seems to occur on 2.4.11 if the fix is intended to be in there

@sumneko
Copy link
Collaborator

sumneko commented Nov 25, 2021

You need to rewrite your code to

---@class MyType
local MyTypeTbl = {}

function MyTypeTbl:init()
end

function MyTypeTbl:GetSomething()
    return 1
end

return {
    MyTypeTbl = MyTypeTbl
}

@sumneko sumneko added the as designed Functioning as intended, will not be modified label Nov 25, 2021
@Feez
Copy link
Author

Feez commented Nov 25, 2021

Ah, I see. Perhaps an error message or some type of diagnosis indicator to indicate this issue for any others that might be relying on this behavior from previous versions?

@sumneko
Copy link
Collaborator

sumneko commented Nov 25, 2021

Ah, I see. Perhaps an error message or some type of diagnosis indicator to indicate this issue for any others that might be relying on this behavior from previous versions?

When I am free, I will add more diagnostics related to LuaDoc.
In fact, this way of writing was wrong before, but there was another bug that happened to make it work. The basic principle of that bug is:

-- this is a bug that has fixed in 2.4.10

---@class A
function mt:init(x, y)
    print(x) -- `x` is A
    print(y) -- `y` is A
    print(self) -- `self` is A, `mt` can be inferred by `self` so `mt` is A
end

@sumneko sumneko closed this as completed Jun 30, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
as designed Functioning as intended, will not be modified
Projects
None yet
Development

No branches or pull requests

2 participants