From 012a762ba8b282284d9cb3d0c7848f529b3fe3e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=80=E8=90=8C=E5=B0=8F=E6=B1=90?= Date: Wed, 23 Dec 2020 17:42:08 +0800 Subject: fix #318 --- changelog.md | 1 + script/parser/guide.lua | 15 ++++++++------- test/definition/bug.lua | 17 +++++++++++++++++ 3 files changed, 26 insertions(+), 7 deletions(-) diff --git a/changelog.md b/changelog.md index 8118e1bb..71a880b2 100644 --- a/changelog.md +++ b/changelog.md @@ -3,6 +3,7 @@ ## 1.8.0 * `NEW` runtime: support nonstandard symbol * `NEW` diagnostic: `close-non-object` +* `FIX` [#318](https://github.com/sumneko/lua-language-server/issues/318) ## 1.7.4 `2020-12-20` diff --git a/script/parser/guide.lua b/script/parser/guide.lua index b07a301e..35658c94 100644 --- a/script/parser/guide.lua +++ b/script/parser/guide.lua @@ -1767,18 +1767,18 @@ function m.searchSameMethodCrossSelf(ref, mark) end function m.searchSameMethod(ref, mark) - if mark['method'] then - return nil - end local nxt = ref.next if not nxt then return nil end - if nxt.type == 'setmethod' then - mark['method'] = true - return ref + if nxt.type ~= 'setmethod' then + return nil + end + if mark[ref] then + return nil end - return nil + mark[ref] = true + return ref end function m.searchSameFieldsCrossMethod(status, ref, start, queue) @@ -1795,6 +1795,7 @@ function m.searchSameFieldsCrossMethod(status, ref, start, queue) local methodStatus = m.status(status) m.searchRefs(methodStatus, method, 'ref') for _, md in ipairs(methodStatus.results) do + mark[md] = true queue[#queue+1] = { obj = md, start = start, diff --git a/test/definition/bug.lua b/test/definition/bug.lua index 9eafe302..8c446123 100644 --- a/test/definition/bug.lua +++ b/test/definition/bug.lua @@ -152,3 +152,20 @@ TEST [[ string.xx = '' string.xx:() ]] + +TEST [[ +---@class Foo +Foo = {} +function Foo:Constructor() + self. = 1 +end + +---@class Foo2: Foo +Foo2 = {} +function Foo2:Constructor() +end + +---@type Foo2 +local v +v. +]] -- cgit v1.2.3