fix(api): preserve ArrayOf metadata #40429

ArrayOf metadata existed before the LuaCATS type documentation refactor and is
useful to typed clients consuming api_info().

Keep Tuple metadata normalized to Array, since tuple element types can be mixed,
but preserve ArrayOf(...) for exported API metadata.

Fixes #38734

AI-assisted: Codex
(cherry picked from commit ea0af59854)
This commit is contained in:
Lewis Russell
2026-06-26 10:50:17 +01:00
committed by github-actions[bot]
parent fa365cedad
commit ea07b60fb1
2 changed files with 21 additions and 5 deletions

View File

@@ -24,7 +24,16 @@ local function real_type(type, exported)
local container = ptype[1]
if container == 'Union' then
return 'Object'
elseif container == 'Tuple' or container == 'ArrayOf' then
elseif container == 'Tuple' then
return 'Array'
elseif container == 'ArrayOf' then
if exported then
local elem = real_type(ptype[2], true)
if ptype[3] then
return ('ArrayOf(%s, %s)'):format(elem, ptype[3])
end
return ('ArrayOf(%s)'):format(elem)
end
return 'Array'
elseif container == 'DictOf' or container == 'DictAs' then
return 'Dict'