-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Fix FlatMap implementation in Result type #10403
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
base: master
Are you sure you want to change the base?
Conversation
This comment was marked as outdated.
This comment was marked as outdated.
For a Result[T], FlatMap should apply f when the result is Ok, and propagate the error unchanged when it's Err. The original code returns r on Ok and tries to use r.left when Err, which is wrong. This commit fixes that. Secondly, the group of FlatMap/AndThen and OrElse functions and methods are now properly tested with new unit tests. fixes lightningnetwork#10401
ddbb18f to
7eb0728
Compare
|
The coveralls checks failing are a false positive. Coverage before: After: |
ziggie1984
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
some code style minor nits - otherwise LGTM
| // Since AndThen is just an alias for FlatMap, we can reuse the same | ||
| // test cases. | ||
| for _, tc := range flatMapTestCases { | ||
| tc := tc |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that is not needed anymore in golang > 1.19 I think
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can also be removed for all the following lines.
| addresses](https://github.com/lightningnetwork/lnd/pull/10341) were added to | ||
| the node announcement and `getinfo` output. | ||
|
|
||
| * A bug in the [implementation of |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not sure if we need release notes, since this function was not used in the LND release anyways, just add a no-changelog label
The
FlatMapmethod for theResulttype has been corrected to apply the provided function when the result isOkand propagate the error unchanged when it isErr.Comprehensive unit tests have been added to ensure proper functionality of FlatMap, AndThen, and OrElse methods.
Fixes #10401