You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
v5: default(Either<L,R>) is now null; suggest a migration-notes entry and refreshing the Bottom remarks
#1565
We are evaluating a move of an open-source library (Encina, .NET 10) from 4.4.9 to 5.0.0-beta-78. As a pilot we migrated its core package: about 1.5 hours including measurement, mostly mechanical edits, and a core test subset of 1974 tests passes. Most of the break was easy to find because it fails to compile. This one was not, so I am sharing it as a suggestion rather than a bug: I understand from #1337 that this is intentional.
What we noticed.Either<L,R> is now an abstract record class (the "Bottom" state is gone), so default(Either<L,R>) is null:
usingLanguageExt;Either<string,int>d=default!;// v4: struct in Bottom state; v5: nullvarresults=newEither<string,int>[3];// v5: three nulls, no compiler diagnosticConsole.WriteLine(disnull);// True in v5Console.WriteLine(d.IsRight);// NullReferenceException in v5
In our code the case was out Either<EncinaError, Unit> error parameters set with error = default; on the success path. With nullable reference types enabled it surfaced only as CS8625 (warnings, which we treat as errors); without NRT, or with arrays and generic default(T), there is no signal at all.
Why I think this deserves a note, not a code change. The reasons in #1337 (pattern matching, no bottom state, transformer nesting) are convincing, and I do not think default can be guarded. But the current documentation points the other way:
The <remarks> on Either<L,R> still describe a Bottom state and BottomException for filtered values.
The Version 5 migration notes list the removed IEnumerable<EitherData> support and the flipped Bi* arguments, but not that Either changed from a struct to a class, nor what that means for default.
Suggestions, smallest first (happy to send a PR for 1 and 2 if you would like; CONTRIBUTING says docs help is welcome):
Add an entry to the Version 5 notes, next to the Bi* entry, along the lines of: "Either<L,R> is now a class. default(Either<L,R>) and uninitialised array elements are null; there is no Bottom state. Use Either.Left<L,R>(...)/Either.Right<L,R>(...) or a nullable annotation where a placeholder is needed. Impact: Medium; mitigation: search for default and new Either<,>[n]."
Refresh the <remarks> on Either<L,R> so it no longer describes the Bottom state, if it no longer applies.
Optional, only if it fits your maintenance budget: a Roslyn analyzer that flags default(Either<,>) and new Either<,>[n]. I know this is more to maintain for a one-person project, so please treat it as a "nice to have if someone offers", not a request.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Hi Paul, and thanks for language-ext.
We are evaluating a move of an open-source library (Encina, .NET 10) from 4.4.9 to
5.0.0-beta-78. As a pilot we migrated its core package: about 1.5 hours including measurement, mostly mechanical edits, and a core test subset of 1974 tests passes. Most of the break was easy to find because it fails to compile. This one was not, so I am sharing it as a suggestion rather than a bug: I understand from #1337 that this is intentional.What we noticed.
Either<L,R>is now an abstract record class (the "Bottom" state is gone), sodefault(Either<L,R>)isnull:In our code the case was
out Either<EncinaError, Unit> errorparameters set witherror = default;on the success path. With nullable reference types enabled it surfaced only as CS8625 (warnings, which we treat as errors); without NRT, or with arrays and genericdefault(T), there is no signal at all.Why I think this deserves a note, not a code change. The reasons in #1337 (pattern matching, no bottom state, transformer nesting) are convincing, and I do not think
defaultcan be guarded. But the current documentation points the other way:<remarks>onEither<L,R>still describe aBottomstate andBottomExceptionfor filtered values.IEnumerable<EitherData>support and the flippedBi*arguments, but not thatEitherchanged from a struct to a class, nor what that means fordefault.Suggestions, smallest first (happy to send a PR for 1 and 2 if you would like; CONTRIBUTING says docs help is welcome):
Bi*entry, along the lines of: "Either<L,R>is now a class.default(Either<L,R>)and uninitialised array elements arenull; there is no Bottom state. UseEither.Left<L,R>(...)/Either.Right<L,R>(...)or a nullable annotation where a placeholder is needed. Impact: Medium; mitigation: search fordefaultandnew Either<,>[n]."<remarks>onEither<L,R>so it no longer describes the Bottom state, if it no longer applies.default(Either<,>)andnew Either<,>[n]. I know this is more to maintain for a one-person project, so please treat it as a "nice to have if someone offers", not a request.Environment:
LanguageExt.Core 5.0.0-beta-78, .NET 10, C# 14. Full migration report (all numbers, including build errors per category): https://github.com/dlrivada/Encina/blob/main/docs/engineering/languageext-v5-spike-1899.mdThank you for your time.
All reactions