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

搜索引用在某些情况会出错,已附上复现用例 #276

Closed
uhziel opened this issue Dec 2, 2020 · 1 comment
Closed

搜索引用在某些情况会出错,已附上复现用例 #276

uhziel opened this issue Dec 2, 2020 · 1 comment
Labels
bug Something isn't working

Comments

@uhziel
Copy link
Contributor

uhziel commented Dec 2, 2020

1 复现方法

在 test\references\init.lua 中添加下面用例,会提示失败

TEST [[
---@class Dog
local mt = {}
function mt:<?eat?>()
end

---@class Master
local mt2 = {}
function mt2:init()
    ---@type Dog
    local foo = self:doSomething()
    ---@type Dog
    self.dog = getDog()
end
function mt2:feed()
    self.dog:<!eat!>()
end
function mt2:doSomething()
end
]]

如果去掉用例其中的这2行,可以通过测试

     ---@type Dog
    local foo = self:doSomething()

2 定位到原因

在处理 searchSameFieldsCrossMethod() 穿透 self 时,因为第一处"---@type Dog" 已穿透一次,status.cache.crossMethodMark 已缓存该self。到第二处"---@type Dog"需要穿透时,因为缓存直接跳过,导致失败。

这块逻辑比较复杂,才开始看这个项目的代码。请交下作者有什么好的处理方法了?

@sumneko sumneko added the bug Something isn't working label Dec 2, 2020
@sumneko
Copy link
Collaborator

sumneko commented Dec 2, 2020

确实挺复杂的,我也要依靠调试才能理清关系,晚点研究一下

@sumneko sumneko closed this as completed in 31a4c20 Dec 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants