-
-
Notifications
You must be signed in to change notification settings - Fork 391
Open
Labels
enhancementNew feature or requestNew feature or request
Description
Some functions, such as error, never return control to the caller. This can be used to prove that a value is not nil, for example:
function my_function(input)
local value = input.value or error('Missing value')
-- The following line would currently raise a "Needs nil check" warning
-- However, if it was nil at runtime, an error would have been raised and it would never get this far.
return value:sub(1, 3)
endIt's not just error that can cause this, however. A custom function could be written that never returns as well (the most obvious way is that the function unconditionally calls error, but there may be other ways involving coroutines or functions implemented in C). A @noreturn annotation could be used to indicate this, similar to @nodiscard.
altermo, KUDr66, applejag and Extrunder
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request