summaryrefslogtreecommitdiff
path: root/server
diff options
context:
space:
mode:
Diffstat (limited to 'server')
-rw-r--r--server/src/core/global.lua17
-rw-r--r--server/src/core/vm.lua15
-rw-r--r--server/test/crossfile/definition.lua22
3 files changed, 41 insertions, 13 deletions
diff --git a/server/src/core/global.lua b/server/src/core/global.lua
index 9dca50d0..655bc1c4 100644
--- a/server/src/core/global.lua
+++ b/server/src/core/global.lua
@@ -26,19 +26,22 @@ end
function mt:compileVM(uri, vm)
local seted = {}
- for k, v in pairs(vm.results.globals) do
- seted[k] = true
- self:markSet(uri, k, v)
+ local fixed = {}
+ for _, data in ipairs(vm.results.globals) do
+ local key = data.global.key
+ fixed[key] = true
+ if data.type == 'global' then
+ seted[key] = true
+ self:markSet(uri, key, data.global)
+ end
end
for k in next, vm.env.child do
- if not seted[k] then
- self:markGet(uri, k)
- end
+ self:markGet(uri, k)
end
local needReCompile = {}
for otherUri, gets in pairs(self.get) do
- for key in pairs(seted) do
+ for key in pairs(fixed) do
if gets[key] ~= nil then
needReCompile[#needReCompile+1] = otherUri
goto CONTINUE
diff --git a/server/src/core/vm.lua b/server/src/core/vm.lua
index a851f859..2f2a5dbf 100644
--- a/server/src/core/vm.lua
+++ b/server/src/core/vm.lua
@@ -379,10 +379,7 @@ function mt:getField(pValue, name, source)
local field = (pValue.child and pValue.child[name])
if not field and pValue.ENV then
if self.lsp then
- local g = self.lsp:getGlobal(name)
- if g then
- field = readOnly(g)
- end
+ field = self.lsp:getGlobal(name)
end
end
if not field then
@@ -1293,7 +1290,10 @@ function mt:doSet(action)
local var = self:getName(key[1], key)
self:setValue(var, value, key)
if self:isGlobal(var) then
- self.results.globals[key[1]] = var
+ self.results.globals[#self.results.globals+1] = {
+ type = 'global',
+ global = var,
+ }
end
elseif key.type == 'simple' then
local field = self:getSimple(key, 'field')
@@ -1301,7 +1301,10 @@ function mt:doSet(action)
local var = field
repeat
if self:isGlobal(var) then
- self.results.globals[var.key] = var
+ self.results.globals[#self.results.globals+1] = {
+ type = 'field',
+ global = var,
+ }
break
end
var = var.parent
diff --git a/server/test/crossfile/definition.lua b/server/test/crossfile/definition.lua
index 396f54c5..458154bc 100644
--- a/server/test/crossfile/definition.lua
+++ b/server/test/crossfile/definition.lua
@@ -217,6 +217,7 @@ TEST {
{
path = 'a.lua',
content = [[
+ x = {}
x.<!global!> = 1
]],
},
@@ -225,5 +226,26 @@ TEST {
content = [[
print(x.<?global?>)
]],
+ },
+}
+
+TEST {
+ {
+ path = 'a.lua',
+ content = [[
+ x.<!global!> = 1
+ ]],
+ },
+ {
+ path = 'b.lua',
+ content = [[
+ print(x.<?global?>)
+ ]],
+ },
+ {
+ path = 'c.lua',
+ content = [[
+ x = {}
+ ]]
}
}