From 28d5a33077b28dcbb52974aaf90125cee013342b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=80=E8=90=8C=E5=B0=8F=E6=B1=90?= Date: Mon, 20 Jun 2022 22:41:29 +0800 Subject: update `array[1] = nil` --- script/core/diagnostics/assign-type-mismatch.lua | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'script/core/diagnostics') diff --git a/script/core/diagnostics/assign-type-mismatch.lua b/script/core/diagnostics/assign-type-mismatch.lua index 37e18d09..30d0f97c 100644 --- a/script/core/diagnostics/assign-type-mismatch.lua +++ b/script/core/diagnostics/assign-type-mismatch.lua @@ -37,8 +37,18 @@ return function (uri, callback) return end end - local varNode = vm.compileNode(source) local valueNode = vm.compileNode(value) + if source.type == 'setindex' + and vm.isSubType(uri, valueNode, 'nil') then + -- boolean[1] = nil + local tnode = vm.compileNode(source.node) + for n in tnode:eachObject() do + if n.type == 'doc.type.array' then + return + end + end + end + local varNode = vm.compileNode(source) if vm.canCastType(uri, varNode, valueNode) then return end -- cgit v1.2.3