summaryrefslogtreecommitdiff
path: root/tools/love-api.lua
diff options
context:
space:
mode:
Diffstat (limited to 'tools/love-api.lua')
-rw-r--r--tools/love-api.lua19
1 files changed, 11 insertions, 8 deletions
diff --git a/tools/love-api.lua b/tools/love-api.lua
index 38653e68..31284cd6 100644
--- a/tools/love-api.lua
+++ b/tools/love-api.lua
@@ -51,13 +51,16 @@ local function formatIndex(key)
end
local function isTableOptional(tbl)
- local optional = true
- for _, field in ipairs(tbl) do
- if field.default == nil then
- optional = nil
- end
- end
- return optional
+ if not tbl then
+ return false
+ end
+ local optional = true
+ for _, field in ipairs(tbl) do
+ if field.default == nil then
+ optional = nil
+ end
+ end
+ return optional
end
local buildType
@@ -156,7 +159,7 @@ local function buildFunction(func, node, typeName)
for _, param in ipairs(func.variants[1].arguments or {}) do
for paramName in param.name:gmatch '[%a_][%w_]*' do
params[#params+1] = paramName
- local optional = param.type == 'table' and isTableOptional(param.table) or (param.default ~= nil)
+ local optional = param.type == 'table' and isTableOptional(param.table) or (param.default ~= nil)
text[#text+1] = ('---@param %s%s %s # %s'):format(
paramName,
optional and '?' or '',