summaryrefslogtreecommitdiff
path: root/src/matcher/definition.lua
diff options
context:
space:
mode:
Diffstat (limited to 'src/matcher/definition.lua')
-rw-r--r--src/matcher/definition.lua14
1 files changed, 11 insertions, 3 deletions
diff --git a/src/matcher/definition.lua b/src/matcher/definition.lua
index 04d01135..a744efed 100644
--- a/src/matcher/definition.lua
+++ b/src/matcher/definition.lua
@@ -32,8 +32,16 @@ end
local function scopeSet(obj)
local name = obj[1]
+ local scope = scopes[#scopes]
+ if not scope[name] then
+ scope[name] = obj
+ end
+end
+
+local function globalSet(obj)
+ local name = obj[1]
if not scopeGet(name) then
- local scope = scopes[#scopes]
+ local scope = scopes[1]
scope[name] = obj
end
end
@@ -97,7 +105,7 @@ function defs.Set(simples)
if simple.type == 'simple' and #simple == 1 then
local obj = simple[1]
local name = obj[1]
- scopeSet(obj)
+ globalSet(obj)
end
end
end
@@ -122,7 +130,7 @@ end
function defs.FunctionDef(simple, args)
if #simple == 1 then
- scopeSet(simple[1])
+ globalSet(simple[1])
end
scopePush()
-- 判断隐藏的局部变量self