summaryrefslogtreecommitdiff
path: root/script/vm
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2022-12-15 21:48:24 +0800
committer最萌小汐 <sumneko@hotmail.com>2022-12-15 21:48:24 +0800
commit3c45587f84aee06d280ca1d5223cf49068a62fb7 (patch)
tree6341f167726f9093eb4067f18a66f1540caf4733 /script/vm
parent6e2d3d42dba22ee9f179546b1e92d0b3313ec1f5 (diff)
downloadlua-language-server-3c45587f84aee06d280ca1d5223cf49068a62fb7.zip
update narrow assign
Diffstat (limited to 'script/vm')
-rw-r--r--script/vm/compiler.lua12
1 files changed, 12 insertions, 0 deletions
diff --git a/script/vm/compiler.lua b/script/vm/compiler.lua
index eefed5a8..e4fb633e 100644
--- a/script/vm/compiler.lua
+++ b/script/vm/compiler.lua
@@ -1180,8 +1180,20 @@ local compilerSwitch = util.switch()
if bindDocs(source) then
return
end
+ local locNode = vm.compileNode(source.node)
+ if not source.value then
+ vm.setNode(source, locNode)
+ return
+ end
local valueNode = vm.compileNode(source.value)
vm.setNode(source, valueNode)
+ if locNode:getData 'hasDefined'
+ and guide.isLiteral(source.value) then
+ vm.setNode(source, locNode)
+ vm.getNode(source):narrow(guide.getUri(source), source.value.type)
+ else
+ vm.setNode(source, valueNode)
+ end
end)
: case 'getlocal'
---@async