-
Notifications
You must be signed in to change notification settings - Fork 816
FS0748 error "This construct may only be used in computation expresions" reported for 'return' when it is not true #4653
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
Comments
@abelbraaksma If it helps, the Agreed the error message could be better here |
Linking to #2739 |
@dsyme, Actually, that makes sense, though it isn't immediately obvious that Say you have this: let x =
result {
let! (a, _) = someResult
return a
},
result {
let! (_, b) = someResult
return b
} Then this seems like a nice shortcut: let x =
result {
let! (a, b) = someResult
return a, return b // creating two returned values, i.e. Result<_> * Result<_>, instead of Result<_,_>
} I've had similar challenges on the But I understand that would be a language change and likely not an orthogonal one. |
I knew I was testing potentially invalid code, but I was surprised to see the error:
Or in text for googleability:
Repro steps
Use something like
return 1, return 2
at the end of any computation expression.Expected behavior
Some syntax error, but not the one mentioned above.
Actual behavior
Error FS0748 as mentioned is reported, but the error says I am not inside a computation expression, while I am.
Known workarounds
Don't listen to the error, but fix your code ;).
Related information
As an aside (as always): it would be interesting to here thoughts on allowing
return x, return y
, but I'm not sure if we can get the behavior defined cleanly. My expectation would be that it would return a tuple of two instances of the computation expression.The text was updated successfully, but these errors were encountered: