Skip to content

Commit

Permalink
fix: can use nested records in global 'table' record
Browse files Browse the repository at this point in the history
  • Loading branch information
hishamhm committed Jul 19, 2024
1 parent 3dc753c commit 64a0fc5
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
5 changes: 5 additions & 0 deletions spec/declaration/local_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,11 @@ describe("local", function()
{ msg = "b" },
}))

it("local type can declare a type alias for table", util.check([[
local type PackTable = table.PackTable
local args: table.PackTable<integer> = table.pack(1, 2, 3)
]]))

it("local type can declare a nominal type alias (regression test for #238)", function ()
util.mock_io(finally, {
["module.tl"] = [[
Expand Down
2 changes: 1 addition & 1 deletion tl.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2586,7 +2586,7 @@ do
local st = simple_types[tk]
if st then
return i + 1, new_type(ps, i, tk)
elseif tk == "table" then
elseif tk == "table" and ps.tokens[i + 1].tk ~= "." then
local typ = new_type(ps, i, "map")
typ.keys = new_type(ps, i, "any")
typ.values = new_type(ps, i, "any")
Expand Down
2 changes: 1 addition & 1 deletion tl.tl
Original file line number Diff line number Diff line change
Expand Up @@ -2586,7 +2586,7 @@ local function parse_simple_type_or_nominal(ps: ParseState, i: integer): integer
local st = simple_types[tk as TypeName]
if st then
return i + 1, new_type(ps, i, tk as TypeName)
elseif tk == "table" then
elseif tk == "table" and ps.tokens[i + 1].tk ~= "." then
local typ = new_type(ps, i, "map") as MapType
typ.keys = new_type(ps, i, "any")
typ.values = new_type(ps, i, "any")
Expand Down

0 comments on commit 64a0fc5

Please sign in to comment.