diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2022-06-17 18:15:13 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2022-06-17 18:15:13 +0800 |
commit | 166504aa87a5b2f7fe6bd41b2c572afccb717534 (patch) | |
tree | 5a61486aca3e1a98a4eeceed13e3ac583d0894eb /script/vm | |
parent | 6431519640a087499ea497066a78a6079993b945 (diff) | |
download | lua-language-server-166504aa87a5b2f7fe6bd41b2c572afccb717534.zip |
update
Diffstat (limited to 'script/vm')
-rw-r--r-- | script/vm/compiler.lua | 18 | ||||
-rw-r--r-- | script/vm/type.lua | 10 |
2 files changed, 18 insertions, 10 deletions
diff --git a/script/vm/compiler.lua b/script/vm/compiler.lua index dd41d7b6..bc85407d 100644 --- a/script/vm/compiler.lua +++ b/script/vm/compiler.lua @@ -637,16 +637,14 @@ local function compileByLocalID(source) end end end - for _, src in ipairs(sources) do - if src.value then - if not hasMarkDoc or guide.isLiteral(src.value) then - if src.value.type ~= 'nil' then - local valueNode = vm.compileNode(src.value) - if valueNode:hasType 'unknown' then - vm.setNode(source, valueNode:copy():remove 'unknown') - else - vm.setNode(source, valueNode) - end + if not hasMarkDoc then + for _, src in ipairs(sources) do + if src.value and src.value.type ~= 'nil' then + local valueNode = vm.compileNode(src.value) + if valueNode:hasType 'unknown' then + vm.setNode(source, valueNode:copy():remove 'unknown') + else + vm.setNode(source, valueNode) end end end diff --git a/script/vm/type.lua b/script/vm/type.lua index 3ad60dae..db378878 100644 --- a/script/vm/type.lua +++ b/script/vm/type.lua @@ -50,6 +50,11 @@ function vm.isSubType(uri, child, parent, mark) return false end end + if child:isOptional() then + if not vm.isSubType(uri, 'nil', parent, mark) then + return false + end + end return true end @@ -64,6 +69,11 @@ function vm.isSubType(uri, child, parent, mark) return true end end + if parent:isOptional() then + if vm.isSubType(uri, child, 'nil', mark) then + return true + end + end return false end |