зеркало из https://github.com/dotnet/fsharp.git
Merge pull request #17491 from dotnet/merges/main-to-release/dev17.12
Merge main to release/dev17.12
This commit is contained in:
Коммит
24116f01e5
|
@ -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
|
||||
|
|
|
@ -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``() =
|
||||
|
|
Загрузка…
Ссылка в новой задаче