diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2022-08-01 15:39:13 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2022-08-01 15:39:13 +0800 |
commit | c2340047debdfa00c1946a113008f7982f68dcb7 (patch) | |
tree | 9d388739cb0809f7fc93f0ed1ff1610d3328e7f8 /script/vm | |
parent | f18a56604200f7ac19a785f6ce52cb7be67979e6 (diff) | |
download | lua-language-server-c2340047debdfa00c1946a113008f7982f68dcb7.zip |
fix #1418
Diffstat (limited to 'script/vm')
-rw-r--r-- | script/vm/compiler.lua | 13 | ||||
-rw-r--r-- | script/vm/function.lua | 2 |
2 files changed, 14 insertions, 1 deletions
diff --git a/script/vm/compiler.lua b/script/vm/compiler.lua index a33eee1f..150ed16f 100644 --- a/script/vm/compiler.lua +++ b/script/vm/compiler.lua @@ -6,6 +6,8 @@ local files = require 'files' ---@class vm local vm = require 'vm.vm' +local LOCK = {} + ---@class parser.object ---@field _compiledNodes boolean ---@field _node vm.node @@ -1161,6 +1163,15 @@ local compilerSwitch = util.switch() vm.setNode(src, vm.createNode(src.value)) vm.setNode(src, node:copy():asTable()) else + guide.eachSource(src.value, function (child) + if child.type == 'getlocal' + and child.node == source then + return + end + if LOCK[child] then + vm.removeNode(child) + end + end) vm.setNode(src, vm.compileNode(src.value), true) end else @@ -1811,9 +1822,11 @@ function vm.compileNode(source) ---@cast source parser.object vm.setNode(source, vm.createNode(), true) + LOCK[source] = true compileByGlobal(source) compileByNode(source) matchCall(source) + LOCK[source] = nil local node = vm.getNode(source) ---@cast node -? diff --git a/script/vm/function.lua b/script/vm/function.lua index f64b2262..148211be 100644 --- a/script/vm/function.lua +++ b/script/vm/function.lua @@ -201,7 +201,7 @@ end ---@return parser.object[] function vm.getMatchedFunctions(func, args, mark) local funcs = {} - local node = vm.compileNode(func) + local node = vm.getNode(func) or vm.compileNode(func) for n in node:eachObject() do if n.type == 'function' or n.type == 'doc.type.function' then |