-
Notifications
You must be signed in to change notification settings - Fork 770
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[WIP] [RFC FS-1060] Nullness checking #15181
base: main
Are you sure you want to change the base?
Conversation
@vzarytovskii @T-Gro I squahed this and also fixed a nasty bug with nullness inference that I spotted while walking through with Vlad on Thursday |
@vzarytovskii @T-Gro This is basically green now :) And much, much trimmed down, with some bugs fixed. I've also revised the TODO list to what would be needed for bringing into preview (It's possible we could even ship preview using the |
I'm going to take care of metadata part |
… for null literal) (#16962)
* Bugfix - matching aliased nullable should strip nullness Eliminating nullness after pattern matching null (that is , for subsequent patterns) must visit contents of abbreviations as well. Otherwise it does not work with the Maybe<T> type whcih we use in the compiler. * Making 'obj' work with new 'not null' constraints in fslib functions Bugfix: obj cannot be passed to generic typars which require T: not null, such as the NonNull active pattern. This commit fixes it. * Bugfix - false 'useless null' warning in nested applications Error fixed: Error on useless null checkwith nullness constraint propagation in code like this:let meTry = Option.ofObj (Path.GetDirectoryName "")`. The warning about 'useless Option.ofObj' points to the string literal, ignoring the string literal is first passed to an API which may return null * Fix import for C# extension methods Bugfix for: C# extension methods which put "?" on the this argument are wrongly interpreted by moving the nullability elsewhere. See AsMemory<T> from System.Memory.dll , this treats byteArray.ToMemory() as resulting in a Memory<byte | null> which is clearly wrong. Also, this now allows to call C# extension methods with ?this to be invoked on a nullable value. * LinkedList First,Last bugfix There was a bug of LinkedList .First and .Last properties not returning nullable nodes. This was fixed by improved byte import in previous commit, adding a regression test for guarding this. * Bugfix: Solve nullness for typars This fixes a bug where `not null` generic constraint was incorrectly passed between two typars:`T1 | null` with not null constraint on T1, and T2 without constraints. This occured when calling Option.ofObj(..) when the inner expression caused solving of generic type arguments, e.g. after (|>) or (id) function. This uses additional inference variable to unify them.
Merge main to feature/nullness
I came across an article about F# Nullness support . As someone who's eagerly awaiting Nullable types including reference types in F#, I want to thank you for this contributions. https://github.com/ken-okabe/vanfs?tab=readme-ov-file#nullable |
Merge main to feature/nullness
…and adds 1x unbox.
Fix issues for plain 'dotnet build Fsharp.Compiler.Service.sln`
* Ignore Nullness applied on structs (C# allows T? when when T is a struct) * Bigfix: Working with CLI events in Fsharp * Bugfix: Mutable binding initially assigned to null should not need type annotation * Solving `let mutable cache = null` via type inference * Enforcing TyparConstraint.IsReferenceType when WithNull type is used * Nullness-related constraint consistency * Bugfix for emitting Nullable attrs for C#
Merge main to feature/nullness
Continuation of #5790 and #6804
This is a prototype implementation of RFC FS-1060 nullable reference types
See tests\adhoc\nullness for testing and samples including baselines of outputs from
/langversion:preview
/langversion:preview /checknulls
TODO:
string | null
and: not null
(@T-Gro )Import+Export
TODOs (to test and adjust if needed)System.Collections.Generic.List<string | null>
)The types 'System.String (...)' and 'System.String (...)' do not have compatible nullability.
which is wrong - either the nullability aren't shown for some reason or the types should be considered compatibleTesting:
To be moved to RFC and resolved, then tested here:
if x then null else ""
andif x then "" else null