From 99691a901cc26bc44720ced49729d436a09129ba 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 15:54:56 +0800 Subject: update --- meta/template/string.lua | 1 - script/service/telemetry.lua | 1 + script/vm/doc.lua | 12 ++++++------ script/vm/type.lua | 3 +++ script/vm/value.lua | 2 +- test/crossfile/hover.lua | 4 ++-- test/diagnostics/type-check.lua | 13 +++++++------ 7 files changed, 20 insertions(+), 16 deletions(-) diff --git a/meta/template/string.lua b/meta/template/string.lua index a27086ff..8f0790d6 100644 --- a/meta/template/string.lua +++ b/meta/template/string.lua @@ -87,7 +87,6 @@ function string.lower(s) end ---@param s string ---@param pattern string ---@param init? integer ----@return string | number captured ---@return ... captured ---@nodiscard function string.match(s, pattern, init) end diff --git a/script/service/telemetry.lua b/script/service/telemetry.lua index 2e52def2..211dff0e 100644 --- a/script/service/telemetry.lua +++ b/script/service/telemetry.lua @@ -90,6 +90,7 @@ local function pushErrorLog(link) )) end +---@type boolean? local isValid = false timer.wait(5, function () diff --git a/script/vm/doc.lua b/script/vm/doc.lua index 6ee00192..31d7f0ff 100644 --- a/script/vm/doc.lua +++ b/script/vm/doc.lua @@ -90,10 +90,10 @@ end ---@return parser.object? local function getDeprecated(value) if not value.bindDocs then - return false + return nil end if value._deprecated ~= nil then - return value._deprecated + return value._deprecated or nil end for _, doc in ipairs(value.bindDocs) do if doc.type == 'doc.deprecated' then @@ -108,7 +108,7 @@ local function getDeprecated(value) end end value._deprecated = false - return false + return nil end ---@return parser.object? @@ -116,9 +116,9 @@ function vm.getDeprecated(value, deep) if deep then local defs = vm.getDefs(value) if #defs == 0 then - return false + return nil end - local deprecated = false + local deprecated for _, def in ipairs(defs) do if def.type == 'setglobal' or def.type == 'setfield' @@ -128,7 +128,7 @@ function vm.getDeprecated(value, deep) or def.type == 'tableindex' then deprecated = getDeprecated(def) if not deprecated then - return false + return nil end end end diff --git a/script/vm/type.lua b/script/vm/type.lua index 15c94dfc..fd4c1a17 100644 --- a/script/vm/type.lua +++ b/script/vm/type.lua @@ -29,6 +29,9 @@ local function getNodeName(object) if object.type == 'doc.type.table' then return 'table' end + if object.type == 'doc.type.array' then + return 'table' + end return nil end diff --git a/script/vm/value.lua b/script/vm/value.lua index d29ca9d0..13e27e59 100644 --- a/script/vm/value.lua +++ b/script/vm/value.lua @@ -141,7 +141,7 @@ function vm.getInteger(v) end ---@param v vm.object? ----@return integer? +---@return string? function vm.getString(v) if not v then return nil diff --git a/test/crossfile/hover.lua b/test/crossfile/hover.lua index 0bf8165b..08cde574 100644 --- a/test/crossfile/hover.lua +++ b/test/crossfile/hover.lua @@ -58,8 +58,8 @@ function TEST(expect) local hover = core.byUri(sourceUri, sourcePos) assert(hover) - hover = tostring(hover):gsub('\r\n', '\n') - assert(eq(hover, expect.hover)) + local content = tostring(hover):gsub('\r\n', '\n') + assert(eq(content, expect.hover)) end TEST { diff --git a/test/diagnostics/type-check.lua b/test/diagnostics/type-check.lua index c8ea17a4..c59d73ed 100644 --- a/test/diagnostics/type-check.lua +++ b/test/diagnostics/type-check.lua @@ -170,10 +170,15 @@ local a t = a ]] -do return end TEST [[ ----@diagnostic disable: unused-local +local m = {} + +---@type integer[] +m.ints = {} +]] +do return end +TEST [[ ---@class A ---@field x integer local t @@ -182,8 +187,6 @@ local t ]] TEST [[ ----@diagnostic disable: unused-local - ---@class A ---@field x integer local t @@ -195,8 +198,6 @@ local y ]] TEST [[ ----@diagnostic disable: unused-local - ---@class A ---@field x integer local t -- cgit v1.2.3