You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Right now to understand whether a function is failable or not, you have to read through its body to find uses of ? or fail. That, or run the compiler and see if it fails with an error message pointing out to a failable function.
Considering that the way a function is called depends on if it is failable, I believe it is a good idea to make it easier to tell them apart — by putting some indication into the function signature.
To be more specific, I propose to make the error a part of the return type signature, using ? at the end of the type:
fun failing(name: Text): Null? {
$command$?
parse(name)?
fail 1
}
// Not sure if this is necessary, if the function doesn't have types anyway
fun failing(name): ? {
$command$?
parse(name)?
fail 1
}
Although, there may be a better way to do this.
The text was updated successfully, but these errors were encountered:
Ph0enixKM
changed the title
[Feature Request] Explicitly mark failable functions in their signatures
[Feature] Explicitly mark failable functions in their signatures
Jul 7, 2024
Right now to understand whether a function is failable or not, you have to read through its body to find uses of
?
orfail
. That, or run the compiler and see if it fails with an error message pointing out to a failable function.Considering that the way a function is called depends on if it is failable, I believe it is a good idea to make it easier to tell them apart — by putting some indication into the function signature.
To be more specific, I propose to make the error a part of the return type signature, using
?
at the end of the type:Although, there may be a better way to do this.
The text was updated successfully, but these errors were encountered: