summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--changelog.md3
-rw-r--r--script/parser/luadoc.lua8
-rw-r--r--test/type_inference/init.lua7
3 files changed, 14 insertions, 4 deletions
diff --git a/changelog.md b/changelog.md
index 68ccd4dd..343422e9 100644
--- a/changelog.md
+++ b/changelog.md
@@ -4,7 +4,8 @@
* `NEW` `VSCode`: click the status bar icon to operate:
* run workspace diagnostics
* `FIX` `debug.getuservalue` and `debug.setuservalue` should not exist in `Lua 5.1`
-* `FIX` infer of `class[][]`
+* `FIX` infer of `---@type class[][]`
+* `FIX` infer of `---@type {}[]`
## 2.2.3
`2021-7-9`
diff --git a/script/parser/luadoc.lua b/script/parser/luadoc.lua
index acb19a25..3a3a0984 100644
--- a/script/parser/luadoc.lua
+++ b/script/parser/luadoc.lua
@@ -388,10 +388,9 @@ local function parseTypeUnitFunction()
return typeUnit
end
-local function parseTypeUnitLiteralTable(parent)
+local function parseTypeUnitLiteralTable()
local typeUnit = {
type = 'doc.type.ltable',
- parent = parent,
start = getStart(),
fields = {},
}
@@ -451,6 +450,9 @@ local function parseTypeUnit(parent, content)
if content == 'fun' then
result = parseTypeUnitFunction()
end
+ if content == '{' then
+ result = parseTypeUnitLiteralTable()
+ end
if not result then
result = {
type = 'doc.type.name',
@@ -565,7 +567,7 @@ function parseType(parent)
end
elseif tp == 'symbol' and content == '{' then
nextToken()
- local typeUnit = parseTypeUnitLiteralTable(result)
+ local typeUnit = parseTypeUnit(result, content)
if not typeUnit then
break
end
diff --git a/test/type_inference/init.lua b/test/type_inference/init.lua
index b5d4db16..a3a06bfd 100644
--- a/test/type_inference/init.lua
+++ b/test/type_inference/init.lua
@@ -894,3 +894,10 @@ TEST 'string[][]' [[
---@type string[][]
local <?t?>
]]
+
+TEST 'table' [[
+---@type {}[]
+local t
+
+local <?v?> = t[1]
+]]