We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Version: vscode-emmyLua-0.8.20
---@class InnerStruct ---@field name string ---@field age number ---@class Foo local M = {} function M:Init() ---@type table<number, InnerStruct> self._testDict = {} end function M:Test1() local id1 = self:GetIdx() -- 此处id1能够正确解析为number类型 local val1 = self._testDict[id1] -- val1为unknown end function M:Test2() local id1 = 1 local val1 = self._testDict[id1] -- val1能够正确解析为InnerStruct end ---@return number function M:GetIdx() return 1 end
以我的理解,上面的代码中Test1, Test2中的val1局部变量都应该是InnerStruct类型。 这里是有bug还是我的用法有问题呢?
Test1
Test2
val1
InnerStruct
The text was updated successfully, but these errors were encountered:
补充: 下面的代码也可以正确解析
function M:Test3() ---@type number local id1 = self:GetIdx() local val1 = self._testDict[id1] end
Sorry, something went wrong.
emmylua的类型推断因为一些设计上的失误全面崩坏, 实际上当local id1 = self:GetIdx()时, id1的真实类型是匿名类型, 他继承自number, 所以无法继续参与推断.
local id1 = self:GetIdx()
另外emmylua语言服务器当前正在重写的过程中, 所以我短时间内也不会修改这个BUG
emmylua的类型推断因为一些设计上的失误全面崩坏, 实际上当local id1 = self:GetIdx()时, id1的真实类型是匿名类型, 他继承自number, 所以无法继续参与推断. 另外emmylua语言服务器当前正在重写的过程中, 所以我短时间内也不会修改这个BUG
这是仅存在vscode插件中的bug吗,我在jetbrain上使用这段代码能够正确解析Test1中val1的类型
vscode emmylua是完全不同的实现, 他是C#写的, 性能和各个方便都远强于intellij-emmylua
No branches or pull requests
Version: vscode-emmyLua-0.8.20
以我的理解,上面的代码中
Test1
,Test2
中的val1
局部变量都应该是InnerStruct
类型。这里是有bug还是我的用法有问题呢?
The text was updated successfully, but these errors were encountered: