summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2019-01-30 18:02:53 +0800
committer最萌小汐 <sumneko@hotmail.com>2019-01-30 18:02:53 +0800
commitb4e36a946a42a35d49290e095ff044f2ffa051e9 (patch)
tree536b6853d0091456e371666c679dd6560ab7e761
parent170d7a2894ca9cb758edc9f75343889552d07e0c (diff)
downloadlua-language-server-b4e36a946a42a35d49290e095ff044f2ffa051e9.zip
调用函数时要截断调用处的局部变量
-rw-r--r--server/src/core/vm.lua1
-rw-r--r--server/test/diagnostics/init.lua8
2 files changed, 9 insertions, 0 deletions
diff --git a/server/src/core/vm.lua b/server/src/core/vm.lua
index e649ecc7..8359c470 100644
--- a/server/src/core/vm.lua
+++ b/server/src/core/vm.lua
@@ -288,6 +288,7 @@ function mt:runFunction(func)
self.chunk:cut 'locals'
self.chunk.func = func
+ self.scope:cut 'locals'
for name, loc in pairs(func.upvalues) do
self.scope.locals[name] = loc
end
diff --git a/server/test/diagnostics/init.lua b/server/test/diagnostics/init.lua
index acaf3249..9df92961 100644
--- a/server/test/diagnostics/init.lua
+++ b/server/test/diagnostics/init.lua
@@ -158,3 +158,11 @@ local function f(<!self!>)
end
f()
]]
+
+TEST [[
+local function f(var)
+ print(var)
+end
+local var
+f(var)
+]]