summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--server/src/matcher/vm.lua5
-rw-r--r--server/test/find_lib/init.lua4
2 files changed, 7 insertions, 2 deletions
diff --git a/server/src/matcher/vm.lua b/server/src/matcher/vm.lua
index 928a954f..2c89b5e7 100644
--- a/server/src/matcher/vm.lua
+++ b/server/src/matcher/vm.lua
@@ -873,9 +873,10 @@ function mt:createEnvironment()
value = self:setValue(field, value)
end
- -- 设置 _G 等于 _ENV
+ -- 设置 _G 使用 _ENV 的child
local g = self:getField(envValue, '_G')
- self:setValue(g, envValue)
+ local gValue = self:getValue(g)
+ gValue.child = envValue.child
end
local function compile(ast)
diff --git a/server/test/find_lib/init.lua b/server/test/find_lib/init.lua
index 31d44dfc..5bd5e8b4 100644
--- a/server/test/find_lib/init.lua
+++ b/server/test/find_lib/init.lua
@@ -99,3 +99,7 @@ ROOT = filesystem.<?current_path?>()
TEST(nil)[[
print(<?insert?>)
]]
+
+TEST '_G' [[
+local x = <?_G?>
+]]