Skip to content

Commit f7e9256

Browse files
committed
fix #307
1 parent 068b2b2 commit f7e9256

File tree

3 files changed

+44
-3
lines changed

3 files changed

+44
-3
lines changed

changelog.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# changelog
22

3+
## 1.7.2
4+
* `FIX` * `FIX` [#307](https://github.com./sumneko/lua-language-server/issues/307)
5+
* `FIX` a lot of runtime errors
6+
37
## 1.7.1
48
`2020-12-16`
59
* `NEW` setting: `diagnostics.neededFileStatus`

script/parser/guide.lua

+15-3
Original file line numberDiff line numberDiff line change
@@ -792,8 +792,16 @@ end
792792

793793
function m.getSimpleName(obj)
794794
if obj.type == 'call' then
795-
local key = obj.args and obj.args[2]
796-
return m.getKeyName(key)
795+
local node = obj.node
796+
if not node then
797+
return
798+
end
799+
if node.special == 'rawset'
800+
or node.special == 'rawget' then
801+
local key = obj.args and obj.args[2]
802+
return m.getKeyName(key)
803+
end
804+
return ('%p'):format(obj)
797805
elseif obj.type == 'table' then
798806
return ('%p'):format(obj)
799807
elseif obj.type == 'select' then
@@ -1141,7 +1149,8 @@ local function buildSimpleList(obj, max)
11411149
list[i] = cur
11421150
break
11431151
elseif cur.type == 'select'
1144-
or cur.type == 'table' then
1152+
or cur.type == 'table'
1153+
or cur.type == 'call' then
11451154
list[i] = cur
11461155
break
11471156
elseif cur.type == 'string' then
@@ -1182,6 +1191,7 @@ function m.getSimple(obj, max)
11821191
or obj.type == 'tablefield'
11831192
or obj.type == 'tableindex'
11841193
or obj.type == 'select'
1194+
or obj.type == 'call'
11851195
or obj.type == 'table'
11861196
or obj.type == 'string'
11871197
or obj.type == 'doc.class.name'
@@ -1410,6 +1420,8 @@ function m.getObjectValue(obj)
14101420
if obj.type == 'call' then
14111421
if obj.node.special == 'rawset' then
14121422
return obj.args[3]
1423+
else
1424+
return obj
14131425
end
14141426
end
14151427
if obj.type == 'select' then

test/crossfile/definition.lua

+25
Original file line numberDiff line numberDiff line change
@@ -615,3 +615,28 @@ TEST {
615615
]]
616616
},
617617
}
618+
619+
TEST {
620+
{
621+
path = 'a.lua',
622+
content = [[
623+
local lib = {}
624+
625+
function lib:fn1()
626+
return self
627+
end
628+
629+
function lib:<!fn2!>()
630+
end
631+
632+
return lib:fn1()
633+
]]
634+
},
635+
{
636+
path = 'b.lua',
637+
content = [[
638+
local app = require 'a'
639+
print(app.<?fn2?>)
640+
]]
641+
},
642+
}

0 commit comments

Comments
 (0)