summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2021-02-23 15:58:42 +0800
committer最萌小汐 <sumneko@hotmail.com>2021-02-23 15:58:42 +0800
commit200067b4d9922335721b54a2d7916bd3e7ba247c (patch)
treeb315d1a85f24c96fb6d368d48e0240178e08bdd7
parent5c48724257e1abdd81eed0d0e72b6a1033571b87 (diff)
downloadlua-language-server-200067b4d9922335721b54a2d7916bd3e7ba247c.zip
fix #406 dont cache infer when not deep
-rw-r--r--changelog.md3
-rw-r--r--script/parser/guide.lua5
-rw-r--r--test/hover/init.lua14
3 files changed, 21 insertions, 1 deletions
diff --git a/changelog.md b/changelog.md
index ae9865e1..9b76de6e 100644
--- a/changelog.md
+++ b/changelog.md
@@ -1,5 +1,8 @@
# changelog
+## 1.16.2
+* `FIX` [#406](https://github.com/sumneko/lua-language-server/issues/406)
+
## 1.16.1
`2021-2-22`
* `FIX` signature: parameters may be misplaced
diff --git a/script/parser/guide.lua b/script/parser/guide.lua
index c34e65f9..53849a52 100644
--- a/script/parser/guide.lua
+++ b/script/parser/guide.lua
@@ -2937,6 +2937,11 @@ end
function m.getRefCache(status, obj, mode)
local isDeep = status.deep
+ if mode == 'infer' then
+ if not isDeep then
+ return nil, nil
+ end
+ end
local globalCache = status.interface.cache and status.interface.cache() or {}
if m.isGlobal(obj) then
obj = m.getKeyName(obj)
diff --git a/test/hover/init.lua b/test/hover/init.lua
index dc9125ed..0cfb501b 100644
--- a/test/hover/init.lua
+++ b/test/hover/init.lua
@@ -439,7 +439,7 @@ t[any] = any
]]
[[
local t: {
- [integer]: integer = 1,
+ [number]: integer = 1,
}
]]
@@ -1526,3 +1526,15 @@ local t: {
a: integer = 1,
}
]]
+
+TEST [[
+---@return number
+local function f() end
+local <?u?> = f()
+print(u.x)
+]]
+[[
+local u: number {
+ x: any,
+}
+]]