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?
local function to_severity(severity)
if type(severity) == 'string' then
return assert(
M.severity[string.upper(severity)],
string.format('Invalid severity: %s', severity)
)
assert(M.severity[string.upper(severity)], string.format('Invalid severity: %s', severity))
return M.severity[string.upper(severity)]
end
return severity
end

View File

@ -77,7 +77,8 @@ function M.to_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
return M

View File

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