Repository navigation
fix(js/ts/python/dart/rust/beam): break min and max ties like FSharp.Core - #5198
Merged
MangelMaxime merged 5 commits intoNov 24, 2026
Merged
Conversation
This was referenced Oct 28, 2026
leonitousconforti
added a commit
to leonitousconforti/flip7
that referenced
this pull request
Nov 6, 2026
Only the min tie, fable-compiler/Fable#5198, is still listed. ParamName and Convert.ToHexString come from Fable now, and Assert.Throws no longer singles out a plain Exception.
leonitousconforti
added a commit
to leonitousconforti/flip7
that referenced
this pull request
Nov 6, 2026
Only the min tie, fable-compiler/Fable#5198, is still listed. ParamName and Convert.ToHexString come from Fable now, and Assert.Throws no longer singles out a plain Exception.
leonitousconforti
added a commit
to leonitousconforti/flip7
that referenced
this pull request
Nov 6, 2026
Fable's List.minBy keeps the last of a tie until fable-compiler/Fable#5198 ships, so until then the fable job fails on this game.
Contributor
Author
|
👋 |
- List, Array and Seq minBy returned the last of the tied minima; they now return the first, and minBy and maxBy call the projection once per element instead of twice per step. - List, Array and Seq min returned the last of equal minima, visible with 1.0m and 1.00m, -0.0 and 0.0 or a custom comparison. They now return the first, like max already did. - The max operator returned its second argument when the values compare equal; it now returns the first like FSharp.Core (min already returned the second, as FSharp.Core does).
- List and Seq minBy returned the last of the tied minima; they now return the first. List, Array and Seq minBy and maxBy call the projection once per element instead of twice per step. - List and Seq min, and Array min and max, returned the last of equal elements (e.g. -0.0 and 0.0); they now return the first. - The max operator returned its second argument when the values compare equal; it now returns the first like FSharp.Core.
- List, Array and Seq minBy returned the last of the tied minima; they now return the first, and minBy and maxBy call the projection once per element instead of twice per step. - List, Array and Seq min returned the last of equal elements (e.g. with a custom comparison); they now return the first, like max already did. - The max operator returned its second argument when the values compare equal; it now returns the first like FSharp.Core. - Float comparison used double.compareTo, which orders -0.0 before 0.0. It now goes through compareDouble, which treats them as equal, in compare, generated record and union comparison, tuples and Set/Map keys. - IComparable.CompareTo goes through compareDynamic, so boxed floats compare 0.0 and -0.0 as equal too.
- List, Array and Seq minBy, maxBy, min and max returned the last of tied elements; they now return the first, comparing each element with the current one like FSharp.Core. minBy and maxBy call the projection once per element instead of twice per step. - The max operator returned its second argument when the values compare equal; it now returns the first like FSharp.Core. - The float max and min operators used f64::max and f64::min, which pick either zero and drop NaN. They now go through maxFloat and minFloat, where max prefers 0.0 over -0.0, min prefers -0.0, and NaN propagates, like Math.Max and Math.Min.
- List and Array minBy and maxBy broke key ties by comparing the elements themselves in Erlang term order, so they returned the smallest or largest of the tied elements. They now return the first, as they already did for union keys. - Seq minBy returned the last of the tied minima, and Seq min the last of equal elements; they now return the first. Seq minBy and maxBy call the projection once per element instead of twice per step. - The float max and min operators returned their first argument for 0.0 and -0.0. They now go through max_float and min_float, where max returns 0.0 and min returns -0.0, like Math.Max and Math.Min. - The min operator on tuples, records and other structural values returned its first argument on a tie. It now goes through min_structural, which returns the second like FSharp.Core. min on unions did the same and now returns the second too.
MangelMaxime
force-pushed
the
fix-min-tie-breaking
branch
from
November 24, 2026 17:03
00e8a07 to
5d8fb66
Compare
Member
|
Thank you for the PR |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
The min/max collection functions and the
maxandminoperators now pick the same element as FSharp.Core when values tie. One commit per target.List/Array/Seq.minByreturned the last of tied minima and now return the first:[ "a", 1; "b", 0; "c", 0 ] |> List.minBy sndgave("c", 0), now("b", 0).minByandmaxByalso call the projection once per element, as FSharp.Core does.List/Array/Seq.minreturned the last of equal elements:List.min [ 1.0m; 1.00m ]gave1.00, now1.0.maxoperator returned its second argument on a tie (e.g. a type with a customCompareTo). FSharp.Core returns the first.minalready matched.Array.max/minkept the last of equal elements too.minBy/minandmaxBy/maxall kept the last of tied elements. The floatmax/minoperators usedf64::max/min, which pick either zero and drop NaN:max 0.0 -0.0gave-0.0andmax nan 1.0gave1.0. They now give0.0andnan, likeMath.Max/Math.Min.double.compareTo, which orders-0.0below0.0, so the two were never a tie:List.max [ -0.0; 0.0 ]gave0.0, now-0.0.compare 0.0 -0.0is now0, also inside tuples, records and unions (compare { X = 0.0 } { X = -0.0 }gave1), asSet/Mapkeys, and through a boxedIComparable.CompareTo.minBy/maxBybroke key ties by Erlang term order of the elements. The floatmax/minoperators returned their first argument for0.0and-0.0(max -0.0 0.0gave-0.0, now0.0).minon tuples, records and unions returned its first argument on a tie, now the second.Notes:
minByreturns. On Rust some NaN results changed to match .NET: the float operators above,maxon tuples with a NaN,List.maxwith a NaN, andmaxin generic code. The remaining NaN differences come fromcompareusing a total order, which seems like a separate issue.