arrow
arrow copied to clipboard
filterOrElse changes behavior for null values in 1.1.4
filterOrElse always returns a left value if the right value is null. This is a breaking change from behavior in 1.1.3.
Example
// filterOrOther works as expected
val resultOther = null.right().filterOrOther({ true }) { "Error" }
println(resultOther) // Prints Either.Right(null)
// Use of filterOrElse
val resultElse = null.right().filterOrElse({ true }) { "Error" }
println(resultElse) // Prints Either.Left(Error)
The regression was introduced in #2830 by migrating filterOrElse to ensure in this Commit
@bwanner, thanks for raising the issue.
TODO: Fix this for Option.
TODO: Fix this for
Option.
I've doubled checked the current Option, and there's no function which may suffer from a similar problem.
(I did so by looking at the code, and also by grepping ?. to check any possible issue with nullability handling).