From 200067b4d9922335721b54a2d7916bd3e7ba247c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=80=E8=90=8C=E5=B0=8F=E6=B1=90?= Date: Tue, 23 Feb 2021 15:58:42 +0800 Subject: fix #406 dont cache infer when not deep --- changelog.md | 3 +++ script/parser/guide.lua | 5 +++++ test/hover/init.lua | 14 +++++++++++++- 3 files changed, 21 insertions(+), 1 deletion(-) 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 = f() +print(u.x) +]] +[[ +local u: number { + x: any, +} +]] -- cgit v1.2.3