Skip to content

Commit

Permalink
Merge pull request #17491 from dotnet/merges/main-to-release/dev17.12
Browse files Browse the repository at this point in the history
Merge main to release/dev17.12
  • Loading branch information
psfinaki authored Aug 6, 2024
2 parents 2f69126 + 9ee9282 commit 24116f0
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Compiler/Checking/ConstraintSolver.fs
Original file line number Diff line number Diff line change
Expand Up @@ -1101,7 +1101,7 @@ and SolveNullnessSubsumesNullness (csenv: ConstraintSolverEnv) m2 (trace: Option
| NullnessInfo.WithNull, NullnessInfo.WithoutNull ->
CompleteD
| NullnessInfo.WithoutNull, NullnessInfo.WithNull ->
if csenv.g.checkNullness then
if csenv.g.checkNullness && not csenv.IsSpeculativeForMethodOverloading then
WarnD(ConstraintSolverNullnessWarningWithTypes(csenv.DisplayEnv, ty1, ty2, n1, n2, csenv.m, m2))
else
CompleteD
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,18 @@ let typeCheckWithStrictNullness cu =
cu
|> withNullnessOptions
|> typecheck

[<Fact>]
let ``Does not duplicate warnings`` () =
FSharp """
module MyLib
let getLength (x: string | null) = x.Length
"""
|> asLibrary
|> typeCheckWithStrictNullness
|> shouldFail
|> withDiagnostics [Error 3261, Line 3, Col 36, Line 3, Col 44, "Nullness warning: The types 'string' and 'string | null' do not have compatible nullability."]


[<Fact>]
let ``Cannot pass possibly null value to a strict function``() =
Expand Down

0 comments on commit 24116f0

Please sign in to comment.