diff options
-rw-r--r-- | server/src/matcher/definition.lua | 9 | ||||
-rw-r--r-- | server/test/definition/table.lua | 18 |
2 files changed, 23 insertions, 4 deletions
diff --git a/server/src/matcher/definition.lua b/server/src/matcher/definition.lua index 08c37a43..12139e62 100644 --- a/server/src/matcher/definition.lua +++ b/server/src/matcher/definition.lua @@ -72,7 +72,7 @@ function mt:getField(parent, key) end function mt:checkVar(var, source) - if not source then + if not var or not source then return end if self:isContainPos(source) then @@ -118,11 +118,12 @@ function mt:searchSimple(simple) if tp == 'call' then self:searchCall(obj) elseif tp == 'name' then - if not obj.index then + if obj.index then + var = nil + self:searchExp(obj) + else var = self:getField(var, obj[1]) self:checkVar(var, obj) - else - var = nil end else if obj.index then diff --git a/server/test/definition/table.lua b/server/test/definition/table.lua index 04700f17..57e61a78 100644 --- a/server/test/definition/table.lua +++ b/server/test/definition/table.lua @@ -56,3 +56,21 @@ local t t[<!"longString"!>] = 1 t[<?[==[longString]==]?>]() ]] + +TEST [[ +local t +t.<!x!> = 1 +t[<?'x'?>]() +]] + +TEST [[ +local t +t.<!a!>.b = 1 +t.<?a?>.b() +]] + +TEST [[ +local t +local <!x!> +t[<?x?>]() +]] |