diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2020-12-22 10:18:43 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2020-12-22 10:18:43 +0800 |
commit | 57cd4d0a87b04f589ca5f6a42c8b2d93aa16dc05 (patch) | |
tree | f39f8b6d2a89133a533b8fb6b0546a467e4834c1 /script | |
parent | 7e1cef23d76df62e116412505a91115cf3573950 (diff) | |
download | lua-language-server-57cd4d0a87b04f589ca5f6a42c8b2d93aa16dc05.zip |
fix
Diffstat (limited to 'script')
-rw-r--r-- | script/core/rename.lua | 3 | ||||
-rw-r--r-- | script/parser/guide.lua | 10 |
2 files changed, 8 insertions, 5 deletions
diff --git a/script/core/rename.lua b/script/core/rename.lua index 95a5ee82..b823cb86 100644 --- a/script/core/rename.lua +++ b/script/core/rename.lua @@ -113,6 +113,9 @@ local function trim(str) end local function isValidName(str) + if not str then + return false + end return str:match '^[%a_][%w_]*$' end diff --git a/script/parser/guide.lua b/script/parser/guide.lua index a8897d62..0d5775e6 100644 --- a/script/parser/guide.lua +++ b/script/parser/guide.lua @@ -1422,7 +1422,7 @@ function m.getObjectValue(obj) end if obj.type == 'field' or obj.type == 'method' then - return obj.parent.value + return obj.parent and obj.parent.value end if obj.type == 'call' then if obj.node.special == 'rawset' then @@ -3576,8 +3576,8 @@ function m.inferCheckBinary(status, source) local v2 = m.getInferLiteral(status, source[2], 'integer') or m.getInferLiteral(status, source[2], 'number') local v - if v1 and v2 then - v = v1 > v2 + if v1 and v2 and v2 ~= 0 then + v = v1 / v2 end status.results = m.allocInfer { type = 'number', @@ -3618,7 +3618,7 @@ function m.inferCheckBinary(status, source) local int, v1, v2 = mathCheck(status, source[1], source[2]) status.results = m.allocInfer { type = int, - value = (v1 and v2) and (v1 % v2) or nil, + value = (v1 and v2 and v2 ~= 0) and (v1 % v2) or nil, source = source, level = 100, } @@ -3627,7 +3627,7 @@ function m.inferCheckBinary(status, source) local int, v1, v2 = mathCheck(status, source[1], source[2]) status.results = m.allocInfer { type = int, - value = (v1 and v2) and (v1 // v2) or nil, + value = (v1 and v2 and v2 ~= 0) and (v1 // v2) or nil, source = source, level = 100, } |