fix(lua): return after assert returns assert message (#27064)

This commit is contained in:
altermo 2024-01-17 20:34:25 +01:00 committed by GitHub
parent f5d59340a6
commit 5aa14e1231
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 6 additions and 9 deletions

View File

@ -180,10 +180,8 @@ local all_namespaces = {}
---@return vim.diagnostic.Severity? ---@return vim.diagnostic.Severity?
local function to_severity(severity) local function to_severity(severity)
if type(severity) == 'string' then if type(severity) == 'string' then
return assert( assert(M.severity[string.upper(severity)], string.format('Invalid severity: %s', severity))
M.severity[string.upper(severity)], return M.severity[string.upper(severity)]
string.format('Invalid severity: %s', severity)
)
end end
return severity return severity
end end

View File

@ -77,7 +77,8 @@ function M.to_lpeg(pattern)
}) })
local lpeg_pattern = p:match(pattern) --[[@as vim.lpeg.Pattern?]] local lpeg_pattern = p:match(pattern) --[[@as vim.lpeg.Pattern?]]
return assert(lpeg_pattern, 'Invalid glob') assert(lpeg_pattern, 'Invalid glob')
return lpeg_pattern
end end
return M return M

View File

@ -1123,10 +1123,8 @@ function M._test()
'if "expected" is given, "actual" is also required' 'if "expected" is given, "actual" is also required'
) )
if expected then if expected then
return assert( assert(cond, ('expected %s, got: %s'):format(vim.inspect(expected), vim.inspect(actual)))
cond, return cond
('expected %s, got: %s'):format(vim.inspect(expected), vim.inspect(actual))
)
else else
return assert(cond) return assert(cond)
end end