Skip to content

Commit

Permalink
wrap multiple returns in parentheses when printing function type
Browse files Browse the repository at this point in the history
This is useful for debug messages.
  • Loading branch information
hishamhm committed Dec 18, 2024
1 parent 3ac7a50 commit b19c566
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
6 changes: 6 additions & 0 deletions tl.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6894,10 +6894,16 @@ local function show_type_base(t, short, seen)
if t.rets.tuple and #t.rets.tuple > 0 then
table.insert(out, ": ")
local rets = {}
if #t.rets.tuple > 1 then
table.insert(out, "(")
end
for i, v in ipairs(t.rets.tuple) do
table.insert(rets, show(v) .. (i == #t.rets.tuple and t.rets.is_va and "..." or ""))
end
table.insert(out, table.concat(rets, ", "))
if #t.rets.tuple > 1 then
table.insert(out, ")")
end
end
return table.concat(out)
elseif t.typename == "number" or
Expand Down
6 changes: 6 additions & 0 deletions tl.tl
Original file line number Diff line number Diff line change
Expand Up @@ -6894,10 +6894,16 @@ local function show_type_base(t: Type, short: boolean, seen: {Type:string}): str
if t.rets.tuple and #t.rets.tuple > 0 then
table.insert(out, ": ")
local rets = {}
if #t.rets.tuple > 1 then
table.insert(out, "(")
end
for i, v in ipairs(t.rets.tuple) do
table.insert(rets, show(v) .. (i == #t.rets.tuple and t.rets.is_va and "..." or ""))
end
table.insert(out, table.concat(rets, ", "))
if #t.rets.tuple > 1 then
table.insert(out, ")")
end
end
return table.concat(out)
elseif t.typename == "number"
Expand Down

0 comments on commit b19c566

Please sign in to comment.