Skip to content

Drop the implicit Entity[] to Entity conversion as well - #866

Merged
Rafael-SOWNet merged 1 commit into
masterfrom
fix/remove-array-set-conversion
Aug 10, 2026
Merged

Drop the implicit Entity[] to Entity conversion as well#866
Rafael-SOWNet merged 1 commit into
masterfrom
fix/remove-array-set-conversion

Conversation

@Rafael-SOWNet

Copy link
Copy Markdown
Collaborator

Closes #861.

#853 removed the implicit conversion from List<Entity> because it made three params overloads uncallable, and kept the one from Entity[] on the narrow ground that it never produced that ambiguity — an array binds to the params overload in its normal form by an identity conversion, which wins outright.

True, and beside the point. As @Happypig375 put it on the issue:

Note that converting an array to a set is inherently information-losing because it removes order and duplicate elements. This shouldn't even be a conversion at all; explicit set construction is used for basically all the set types out there.

An array carries an order and can repeat an element; a set has neither. The conversion silently discarded part of what it was handed, and that disqualifies it on its own — the question to ask of an implicit conversion is what it loses, not whether it breaks an overload today.

Entity set = new Entity[] { 1, 2, 3 };          // no longer compiles
Entity set = new FiniteSet(1, 2, 3);            // say it
Entity set = new Entity[] { 1, 2, 3 }.ToSet();

Blast radius, measured before writing anything

Removing the conversion broke exactly one place in the repository: the test from #853 that pinned it. Nothing in the library, no other test, no sample, no wrapper.

That test now asserts the opposite and still earns its keep the same way — the file compiling is what says the conversion has not come back, which no runtime assertion could catch.

PublicApi.txt updated, and the BREAKING-CHANGES.md entry from #853 is widened to cover both conversions as one story, including why keeping this one was the wrong call.

Verification

  • 6084 C# tests pass, 0 failed
  • 130 F# wrapper tests pass
  • PublicApiSurfaceTest green

Breaking, so it wants the 2.0 window — which is the whole reason the question was filed rather than left as a comment.

🤖 Generated with Claude Code

Closes #861.

#853 removed the conversion from List<Entity> because it made three params overloads
uncallable, and kept the one from Entity[] on the narrow ground that it never produced
that ambiguity -- an array binds to the params overload in its normal form by an identity
conversion, which wins outright.

True, and beside the point, as Happypig375 pointed out on the issue: an array carries an
order and can repeat an element, a set has neither, so the conversion silently discarded
part of what it was handed. That disqualifies it on its own. The question to ask of an
implicit conversion is what it loses, not whether it breaks an overload today, and set
types are built explicitly nearly everywhere for this reason.

Measured before writing anything: removing it broke exactly one place in the repository,
which was the test pinning it. Nothing in the library, no other test, no sample.

That test now says the opposite, and still earns its keep the same way -- the file
compiling is what says the conversion has not come back.

Verified: 6084 C# tests and 130 F# tests pass.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@Rafael-SOWNet
Rafael-SOWNet merged commit c6b03b1 into master Aug 10, 2026
25 checks passed
@Rafael-SOWNet
Rafael-SOWNet deleted the fix/remove-array-set-conversion branch August 10, 2026 16:37
Rafael-SOWNet added a commit that referenced this pull request Aug 10, 2026
* Drop the implicit Entity[] to Entity conversion as well

Closes #861.

#853 removed the conversion from List<Entity> because it made three params overloads
uncallable, and kept the one from Entity[] on the narrow ground that it never produced
that ambiguity -- an array binds to the params overload in its normal form by an identity
conversion, which wins outright.

True, and beside the point, as Happypig375 pointed out on the issue: an array carries an
order and can repeat an element, a set has neither, so the conversion silently discarded
part of what it was handed. That disqualifies it on its own. The question to ask of an
implicit conversion is what it loses, not whether it breaks an overload today, and set
types are built explicitly nearly everywhere for this reason.

Measured before writing anything: removing it broke exactly one place in the repository,
which was the test pinning it. Nothing in the library, no other test, no sample.

That test now says the opposite, and still earns its keep the same way -- the file
compiling is what says the conversion has not come back.

Verified: 6084 C# tests and 130 F# tests pass.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* Drop the implicit pair to Interval conversion

Closes #867.

A two-element tuple became an Interval with both endpoints included. A tuple says nothing
about whether either endpoint is in, so the conversion had to supply that, and it chose the
reading opposite to the notation: (1, 5) is the open interval in ordinary mathematical
writing, and this produced the closed one. A caller writing what looks like an open
interval got a closed one, with 1 a member of it, and nothing said so.

Where the array conversion removed in #866 dropped information that was there, this one
produced information that was not. Same fault from the other side, and the same remedy --
ask for the interval by name, which makes the choice visible instead of assumed:

    MathS.Interval(1, 5)                 closed
    MathS.Interval(1, false, 5, false)   open

Measured before writing anything: nothing in the library, the tests, the F# wrapper or the
utilities used it. Zero compile errors on removal, where #866 had one.

The other pairs in the API are left alone, and checked rather than assumed: an integration
Range, the arguments of Substitute, the cases of MathS.Piecewise and ToProvided are all
ordered pairs whose halves have distinct stated roles. None of them has to guess what it
was handed.

Verified: 6085 C# tests and 130 F# tests pass.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Should the implicit Entity[] to Entity conversion go too?

1 participant