From 3c45587f84aee06d280ca1d5223cf49068a62fb7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=80=E8=90=8C=E5=B0=8F=E6=B1=90?= Date: Thu, 15 Dec 2022 21:48:24 +0800 Subject: update narrow assign --- script/vm/compiler.lua | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'script/vm') 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 -- cgit v1.2.3