diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2022-04-16 03:56:56 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2022-04-16 03:56:56 +0800 |
commit | b96fcdde819031b20c49e2070a3aaf070fb74088 (patch) | |
tree | 7e214de44b1f11e1183257472277c3cba4b7a17b /script/vm/type.lua | |
parent | 6c5594a2026604d47d3c94ae07d0514b6616d63b (diff) | |
download | lua-language-server-b96fcdde819031b20c49e2070a3aaf070fb74088.zip |
#1058 fix runtime errors
Diffstat (limited to 'script/vm/type.lua')
-rw-r--r-- | script/vm/type.lua | 26 |
1 files changed, 19 insertions, 7 deletions
diff --git a/script/vm/type.lua b/script/vm/type.lua index 5c8a8088..fa02d19e 100644 --- a/script/vm/type.lua +++ b/script/vm/type.lua @@ -78,7 +78,9 @@ function vm.getTableValue(uri, tnode, knode) if tn.type == 'doc.type.table' then for _, field in ipairs(tn.fields) do if vm.isSubType(uri, vm.compileNode(field.name), knode) then - result:merge(vm.compileNode(field.extends)) + if field.extends then + result:merge(vm.compileNode(field.extends)) + end end end end @@ -88,16 +90,22 @@ function vm.getTableValue(uri, tnode, knode) if tn.type == 'table' then for _, field in ipairs(tn) do if field.type == 'tableindex' then - result:merge(vm.compileNode(field.value)) + if field.value then + result:merge(vm.compileNode(field.value)) + end end if field.type == 'tablefield' then if vm.isSubType(uri, knode, 'string') then - result:merge(vm.compileNode(field.value)) + if field.value then + result:merge(vm.compileNode(field.value)) + end end end if field.type == 'tableexp' then if vm.isSubType(uri, knode, 'integer') and field.tindex == 1 then - result:merge(vm.compileNode(field.value)) + if field.value then + result:merge(vm.compileNode(field.value)) + end end end end @@ -118,8 +126,10 @@ function vm.getTableKey(uri, tnode, vnode) for tn in tnode:eachObject() do if tn.type == 'doc.type.table' then for _, field in ipairs(tn.fields) do - if vm.isSubType(uri, vm.compileNode(field.extends), vnode) then - result:merge(vm.compileNode(field.name)) + if field.extends then + if vm.isSubType(uri, vm.compileNode(field.extends), vnode) then + result:merge(vm.compileNode(field.name)) + end end end end @@ -129,7 +139,9 @@ function vm.getTableKey(uri, tnode, vnode) if tn.type == 'table' then for _, field in ipairs(tn) do if field.type == 'tableindex' then - result:merge(vm.compileNode(field.index)) + if field.index then + result:merge(vm.compileNode(field.index)) + end end if field.type == 'tablefield' then result:merge(globalMgr.getGlobal('type', 'string')) |