-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
return error() in match #16387
Comments
It is a logical error. Because you're trying to assign to a variable, it expects something assignable to come from every branch in the match. A return statement doesn't give anything assignable, so you get the error message you saw. You would need to change the code to something like fn foo() !{
s := match true {
true { 'a' }
else { '' }
}
if s == '' { return error('') }
println(s)
} |
I know it. This is a matter of design. Will to implement this syntax or not. Error handling is still in its infancy. Thanks to their progressive attitude, the current It would be great to see the same progressive attitude and improvement with regard to error handling. Same concept as fn bar() !string{
return error('')
}
fn foo() !{
s := match true {
true { 'a' }
else { bar()! }
}
println(s)
} |
fn foo() !{
s := match true {
true { 'a' }
else { '' }
}
if s == '' { return error('') }
println(s)
} One of the problems of this code is when |
V version: 0.3.2 993e21e
OS: ArchLinux
What did you do?
What did you expect to see?
No error, don't know if this is a bug or not.
What did you see instead?
The text was updated successfully, but these errors were encountered: