Bugfix: In CE's with .BindReturn(..), return inside if-then (without else) stopped working with F# 5.0. #14521
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
See the added tests and the linked issue.
This has been introduced with the possibility to do a optimized .BindReturn (in one operation).
When used inside an if-then; without else; this started to fail with F# 5.0, but was working in F# 4.7.
After some attempts of making it go trough the .BindReturn even when conditional is used (by passing in the result of .Zero() into the 'then' expression, and letting it go via .BindReturn all the time), I did not manage to make it work.
Instead, if such situation is detected, the expression will fallback to using regular .Bind + .Return calls, just like it did in F# 4.7.
This affects code which was not compiling at F# 5.0 and later at all.
Summary of behavior depending on F# version:
Why I agree with @gusty that this was a bug+regression and should be fixed: