Skip to content

Commit ec2b3d9

Browse files
authored
Make nullness equivalent warning message clearer. (#18172)
1 parent dfffae6 commit ec2b3d9

18 files changed

+42
-43
lines changed

src/Compiler/Driver/CompilerDiagnostics.fs

+2-3
Original file line numberDiff line numberDiff line change
@@ -438,7 +438,7 @@ module OldStyleMessages =
438438
let ConstraintSolverTupleDiffLengthsE () = Message("ConstraintSolverTupleDiffLengths", "%d%d")
439439
let ConstraintSolverInfiniteTypesE () = Message("ConstraintSolverInfiniteTypes", "%s%s")
440440
let ConstraintSolverMissingConstraintE () = Message("ConstraintSolverMissingConstraint", "%s")
441-
let ConstraintSolverNullnessWarningEquivWithTypesE () = Message("ConstraintSolverNullnessWarningEquivWithTypes", "%s%s")
441+
let ConstraintSolverNullnessWarningEquivWithTypesE () = Message("ConstraintSolverNullnessWarningEquivWithTypes", "%s")
442442
let ConstraintSolverNullnessWarningWithTypesE () = Message("ConstraintSolverNullnessWarningWithTypes", "%s%s")
443443
let ConstraintSolverNullnessWarningWithTypeE () = Message("ConstraintSolverNullnessWarningWithType", "%s")
444444
let ConstraintSolverNullnessWarningE () = Message("ConstraintSolverNullnessWarning", "%s")
@@ -678,8 +678,7 @@ type Exception with
678678

679679
let t1, t2, _cxs = NicePrint.minimalStringsOfTwoTypes denv ty1 ty2
680680

681-
os.Append(ConstraintSolverNullnessWarningEquivWithTypesE().Format t1 t2)
682-
|> ignore
681+
os.Append(ConstraintSolverNullnessWarningEquivWithTypesE().Format t1) |> ignore
683682

684683
if m.StartLine <> m2.StartLine then
685684
os.Append(SeeAlsoE().Format(stringOfRange m)) |> ignore

src/Compiler/FSStrings.resx

+1-1
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@
130130
<value>A type parameter is missing a constraint '{0}'</value>
131131
</data>
132132
<data name="ConstraintSolverNullnessWarningEquivWithTypes" xml:space="preserve">
133-
<value>Nullness warning: The types '{0}' and '{1}' do not have equivalent nullability.</value>
133+
<value>Nullness warning: A non-nullable '{0}' was expected but this expression is nullable. Consider either changing the target to also be nullable, or use pattern matching to safely handle the null case of this expression.</value>
134134
</data>
135135
<data name="ConstraintSolverNullnessWarningWithTypes" xml:space="preserve">
136136
<value>Nullness warning: The types '{0}' and '{1}' do not have compatible nullability.</value>

src/Compiler/xlf/FSStrings.cs.xlf

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Compiler/xlf/FSStrings.de.xlf

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Compiler/xlf/FSStrings.es.xlf

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Compiler/xlf/FSStrings.fr.xlf

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Compiler/xlf/FSStrings.it.xlf

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Compiler/xlf/FSStrings.ja.xlf

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Compiler/xlf/FSStrings.ko.xlf

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Compiler/xlf/FSStrings.pl.xlf

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Compiler/xlf/FSStrings.pt-BR.xlf

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Compiler/xlf/FSStrings.ru.xlf

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Compiler/xlf/FSStrings.tr.xlf

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Compiler/xlf/FSStrings.zh-Hans.xlf

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Compiler/xlf/FSStrings.zh-Hant.xlf

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/FSharp.Compiler.ComponentTests/Language/Nullness/NullableCsharpImportTests.fs

+7-7
Original file line numberDiff line numberDiff line change
@@ -107,9 +107,9 @@ let y:System.Collections.Generic.LinkedListNode<string> = ll.First
107107
|> shouldFail
108108
|> withDiagnostics
109109
[ Error 3261, Line 4, Col 59, Line 4, Col 66, "Nullness warning: The types 'System.Collections.Generic.LinkedListNode<string>' and 'System.Collections.Generic.LinkedListNode<string> | null' do not have compatible nullability."
110-
Error 3261, Line 4, Col 59, Line 4, Col 66, "Nullness warning: The types 'System.Collections.Generic.LinkedListNode<string>' and 'System.Collections.Generic.LinkedListNode<string> | null' do not have equivalent nullability."
110+
Error 3261, Line 4, Col 59, Line 4, Col 66, "Nullness warning: A non-nullable 'System.Collections.Generic.LinkedListNode<string>' was expected but this expression is nullable. Consider either changing the target to also be nullable, or use pattern matching to safely handle the null case of this expression."
111111
Error 3261, Line 5, Col 59, Line 5, Col 67, "Nullness warning: The types 'System.Collections.Generic.LinkedListNode<string>' and 'System.Collections.Generic.LinkedListNode<string> | null' do not have compatible nullability."
112-
Error 3261, Line 5, Col 59, Line 5, Col 67, "Nullness warning: The types 'System.Collections.Generic.LinkedListNode<string>' and 'System.Collections.Generic.LinkedListNode<string> | null' do not have equivalent nullability."]
112+
Error 3261, Line 5, Col 59, Line 5, Col 67, "Nullness warning: A non-nullable 'System.Collections.Generic.LinkedListNode<string>' was expected but this expression is nullable. Consider either changing the target to also be nullable, or use pattern matching to safely handle the null case of this expression." ]
113113

114114
[<FactForNETCOREAPP>]
115115
let ``Nullable directory info show warn on prop access`` () =
@@ -219,12 +219,12 @@ let ``Consumption of nullable C# - no generics, just strings in methods and fiel
219219
|> shouldFail
220220
|> withDiagnostics [
221221
Error 3261, Line 5, Col 40, Line 5, Col 85, "Nullness warning: The types 'string' and 'string | null' do not have compatible nullability."
222-
Error 3261, Line 5, Col 40, Line 5, Col 85, "Nullness warning: The types 'string' and 'string | null' do not have equivalent nullability."
223-
Error 3261, Line 14, Col 34, Line 14, Col 62, "Nullness warning: The types 'string' and 'string | null' do not have equivalent nullability."
222+
Error 3261, Line 5, Col 40, Line 5, Col 85, "Nullness warning: A non-nullable 'string' was expected but this expression is nullable. Consider either changing the target to also be nullable, or use pattern matching to safely handle the null case of this expression."
223+
Error 3261, Line 14, Col 34, Line 14, Col 62, "Nullness warning: A non-nullable 'string' was expected but this expression is nullable. Consider either changing the target to also be nullable, or use pattern matching to safely handle the null case of this expression."
224224
Error 3261, Line 16, Col 35, Line 16, Col 39, "Nullness warning: The type 'string' does not support 'null'."
225-
Error 3261, Line 25, Col 85, Line 25, Col 97, "Nullness warning: The types 'string' and 'string | null' do not have equivalent nullability."
226-
Error 3261, Line 28, Col 99, Line 28, Col 111, "Nullness warning: The types 'string' and 'string | null' do not have equivalent nullability."
227-
Error 3261, Line 30, Col 97, Line 30, Col 109, "Nullness warning: The types 'string' and 'string | null' do not have equivalent nullability."]
225+
Error 3261, Line 25, Col 85, Line 25, Col 97, "Nullness warning: A non-nullable 'string' was expected but this expression is nullable. Consider either changing the target to also be nullable, or use pattern matching to safely handle the null case of this expression."
226+
Error 3261, Line 28, Col 99, Line 28, Col 111, "Nullness warning: A non-nullable 'string' was expected but this expression is nullable. Consider either changing the target to also be nullable, or use pattern matching to safely handle the null case of this expression."
227+
Error 3261, Line 30, Col 97, Line 30, Col 109, "Nullness warning: A non-nullable 'string' was expected but this expression is nullable. Consider either changing the target to also be nullable, or use pattern matching to safely handle the null case of this expression."]
228228

229229

230230
[<FactForNETCOREAPP>]

0 commit comments

Comments
 (0)