arrow icon indicating copy to clipboard operation
arrow copied to clipboard

filterOrElse changes behavior for null values in 1.1.4

Open bwanner opened this issue 3 years ago • 3 comments

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 avatar Feb 15 '23 21:02 bwanner

@bwanner, thanks for raising the issue.

dberg avatar Feb 15 '23 22:02 dberg

TODO: Fix this for Option.

nomisRev avatar Feb 17 '23 10:02 nomisRev

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).

serras avatar Mar 24 '23 13:03 serras