From aef7b930c0a5774ba78dc0e38a142e667f33a4af Mon Sep 17 00:00:00 2001 From: Tomas Grosup Date: Thu, 7 Nov 2024 08:00:47 +0100 Subject: [PATCH 1/3] Fix missing nullness warning in case of multiple applicable candidates for method resolution (e.g. string and ROS) (#17918) * speculativeForoverloads exclusion was a mistake * DateTime not annotated on desktop * release notes --- .../.FSharp.Compiler.Service/9.0.200.md | 1 + src/Compiler/Checking/ConstraintSolver.fs | 3 +-- .../Nullness/NullableReferenceTypesTests.fs | 17 +++++++++++++++++ 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/docs/release-notes/.FSharp.Compiler.Service/9.0.200.md b/docs/release-notes/.FSharp.Compiler.Service/9.0.200.md index 0c604f1aa0d..360572c6093 100644 --- a/docs/release-notes/.FSharp.Compiler.Service/9.0.200.md +++ b/docs/release-notes/.FSharp.Compiler.Service/9.0.200.md @@ -9,6 +9,7 @@ * Fix concurrency issue in `ILPreTypeDefImpl` ([PR #17812](https://github.com/dotnet/fsharp/pull/17812)) * Fix nullness inference for member val and other OO scenarios ([PR #17845](https://github.com/dotnet/fsharp/pull/17845)) * Fix internal error when analyzing incomplete inherit member ([PR #17905](https://github.com/dotnet/fsharp/pull/17905)) +* Fix missing nullness warning in case of method resolution multiple candidates ([PR #17917](https://github.com/dotnet/fsharp/pull/17918)) ### Added diff --git a/src/Compiler/Checking/ConstraintSolver.fs b/src/Compiler/Checking/ConstraintSolver.fs index 6c79c33be97..6d59c68c7e8 100644 --- a/src/Compiler/Checking/ConstraintSolver.fs +++ b/src/Compiler/Checking/ConstraintSolver.fs @@ -1035,7 +1035,6 @@ and SolveTypMeetsTyparConstraints (csenv: ConstraintSolverEnv) ndeep m2 trace ty and shouldWarnUselessNullCheck (csenv:ConstraintSolverEnv) = csenv.g.checkNullness && - csenv.IsSpeculativeForMethodOverloading = false && csenv.SolverState.WarnWhenUsingWithoutNullOnAWithNullTarget.IsSome // nullness1: actual @@ -1102,7 +1101,7 @@ and SolveNullnessSubsumesNullness (csenv: ConstraintSolverEnv) m2 (trace: Option | NullnessInfo.WithNull, NullnessInfo.WithoutNull -> CompleteD | NullnessInfo.WithoutNull, NullnessInfo.WithNull -> - if csenv.g.checkNullness && not csenv.IsSpeculativeForMethodOverloading then + if csenv.g.checkNullness then WarnD(ConstraintSolverNullnessWarningWithTypes(csenv.DisplayEnv, ty1, ty2, n1, n2, csenv.m, m2)) else CompleteD diff --git a/tests/FSharp.Compiler.ComponentTests/Language/Nullness/NullableReferenceTypesTests.fs b/tests/FSharp.Compiler.ComponentTests/Language/Nullness/NullableReferenceTypesTests.fs index 0da1169b9a8..2933d00e438 100644 --- a/tests/FSharp.Compiler.ComponentTests/Language/Nullness/NullableReferenceTypesTests.fs +++ b/tests/FSharp.Compiler.ComponentTests/Language/Nullness/NullableReferenceTypesTests.fs @@ -19,6 +19,23 @@ let typeCheckWithStrictNullness cu = +[] +let ``Does report when null goes to DateTime Parse`` () = + + FSharp """module TestLib +open System +let parsedDate = DateTime.Parse(null:(string|null)) +let parseDate2(s:string|null) = DateTime.Parse(s) +let parsedDate3 = DateTime.Parse(null) + """ + |> asLibrary + |> typeCheckWithStrictNullness + |> shouldFail + |> withDiagnostics + [Error 3261, Line 3, Col 18, Line 3, Col 52, "Nullness warning: The types 'string' and 'string | null' do not have compatible nullability." + Error 3261, Line 4, Col 33, Line 4, Col 50, "Nullness warning: The types 'string' and 'string | null' do not have compatible nullability." + Error 3261, Line 5, Col 19, Line 5, Col 39, "Nullness warning: The type 'string' does not support 'null'."] + [] let ``Can convert generic value to objnull arg`` () = FSharp """module TestLib From 4bd7da7b113a33d2d3381f68e312087dce624b14 Mon Sep 17 00:00:00 2001 From: Tomas Grosup Date: Thu, 7 Nov 2024 08:01:46 +0100 Subject: [PATCH 2/3] Update README.md with contributor call out (#17946) --- README.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/README.md b/README.md index ee55e75dfad..0def09e17fe 100644 --- a/README.md +++ b/README.md @@ -57,6 +57,12 @@ After it's finished, open `FSharp.sln` in your editor of choice. Even if you find a single-character typo, we're happy to take the change! Although the codebase can feel daunting for beginners, we and other contributors are happy to help you along. +Not sure where to contribute? +Look at the [curated list of issues asking for help](https://github.com/dotnet/fsharp/issues?q=is%3Aissue%20state%3Aopen%20label%3A%22help%20wanted%22). If you want to tackle any of those, use the comments section of the chosen issue to indicate interest and feel free to ask for initial guidance. We are happy to help with resolving outstanding issues while making a successful PR addressing the issue. + +The issues in this repository can have big differences in the complexity for fixing them. +Are you getting started? We do have a label for [good first issues](https://github.com/dotnet/fsharp/issues?q=is%3Aissue%20state%3Aopen%20label%3A%22good%20first%20issue%22) as well. + ## Per-build NuGet packages ### 7.0.40x series From 277f6760f255584a93a239bdb6d8235195e4d5f2 Mon Sep 17 00:00:00 2001 From: "dotnet-maestro[bot]" <42748379+dotnet-maestro[bot]@users.noreply.github.com> Date: Thu, 7 Nov 2024 11:23:17 +0100 Subject: [PATCH 3/3] [main] Update dependencies from dotnet/source-build-reference-packages (#17937) --- eng/Version.Details.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/eng/Version.Details.xml b/eng/Version.Details.xml index ec75e2b3ec2..72e666ba74d 100644 --- a/eng/Version.Details.xml +++ b/eng/Version.Details.xml @@ -1,9 +1,9 @@ - + https://github.com/dotnet/source-build-reference-packages - ccd0927e3823fb178c7151594f5d2eaba81bba81 + e781442b88c4d939f06a94f38f24a5dc18c383d4