diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2019-03-26 16:34:57 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2019-03-26 16:34:57 +0800 |
commit | 9c439e08cddd69ea332c320d3ee213d2b64c5a03 (patch) | |
tree | dfc292bfb7775868f9a1823d01fabe2404beb9f5 /server/src/vm | |
parent | 09d31b022f33e5c5e8875117c0a6ea51e37ebcb1 (diff) | |
download | lua-language-server-9c439e08cddd69ea332c320d3ee213d2b64c5a03.zip |
修正报错
Diffstat (limited to 'server/src/vm')
-rw-r--r-- | server/src/vm/function.lua | 12 | ||||
-rw-r--r-- | server/src/vm/library.lua | 5 | ||||
-rw-r--r-- | server/src/vm/value.lua | 3 |
3 files changed, 12 insertions, 8 deletions
diff --git a/server/src/vm/function.lua b/server/src/vm/function.lua index 8e2478ca..834863d6 100644 --- a/server/src/vm/function.lua +++ b/server/src/vm/function.lua @@ -270,12 +270,12 @@ function mt:getSource() end local function create(source) - local id - if source then - id = source.id - if not id then - error('Not instanted source') - end + if not source then + error('Function need source') + end + local id = source.id + if not id then + error('Not instanted source') end local self = setmetatable({ source = id, diff --git a/server/src/vm/library.lua b/server/src/vm/library.lua index ed5c2e7f..6f038554 100644 --- a/server/src/vm/library.lua +++ b/server/src/vm/library.lua @@ -22,8 +22,9 @@ function buildLibValue(lib) if tp == 'table' then value = valueMgr.create('table', sourceMgr.dummy()) elseif tp == 'function' then - value = valueMgr.create('function', sourceMgr.dummy()) - local func = functionMgr.create() + local dummySource = sourceMgr.dummy() + value = valueMgr.create('function', dummySource) + local func = functionMgr.create(dummySource) value:setFunction(func) if lib.args then for _, arg in ipairs(lib.args) do diff --git a/server/src/vm/value.lua b/server/src/vm/value.lua index a51040b4..cfcdb66d 100644 --- a/server/src/vm/value.lua +++ b/server/src/vm/value.lua @@ -385,6 +385,9 @@ end function mt:getFunction() local func = self._func + if not func then + return nil + end if not func:getSource() then self._func = nil end |