Skip to content

Commit 64a0fc5

Browse files
committed
fix: can use nested records in global 'table' record
1 parent 3dc753c commit 64a0fc5

File tree

3 files changed

+7
-2
lines changed

3 files changed

+7
-2
lines changed

spec/declaration/local_spec.lua

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,11 @@ describe("local", function()
9898
{ msg = "b" },
9999
}))
100100

101+
it("local type can declare a type alias for table", util.check([[
102+
local type PackTable = table.PackTable
103+
local args: table.PackTable<integer> = table.pack(1, 2, 3)
104+
]]))
105+
101106
it("local type can declare a nominal type alias (regression test for #238)", function ()
102107
util.mock_io(finally, {
103108
["module.tl"] = [[

tl.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2586,7 +2586,7 @@ do
25862586
local st = simple_types[tk]
25872587
if st then
25882588
return i + 1, new_type(ps, i, tk)
2589-
elseif tk == "table" then
2589+
elseif tk == "table" and ps.tokens[i + 1].tk ~= "." then
25902590
local typ = new_type(ps, i, "map")
25912591
typ.keys = new_type(ps, i, "any")
25922592
typ.values = new_type(ps, i, "any")

tl.tl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2586,7 +2586,7 @@ local function parse_simple_type_or_nominal(ps: ParseState, i: integer): integer
25862586
local st = simple_types[tk as TypeName]
25872587
if st then
25882588
return i + 1, new_type(ps, i, tk as TypeName)
2589-
elseif tk == "table" then
2589+
elseif tk == "table" and ps.tokens[i + 1].tk ~= "." then
25902590
local typ = new_type(ps, i, "map") as MapType
25912591
typ.keys = new_type(ps, i, "any")
25922592
typ.values = new_type(ps, i, "any")

0 commit comments

Comments
 (0)