Skip to content

Commit 88ae3f8

Browse files
committed
Add test triggering Nullable builtin conversion warning
1 parent 09f775e commit 88ae3f8

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

tests/fsharp/Compiler/Language/TypeDirectedConversionTests.fs

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,26 @@ let test() =
243243
M.A(Result<int, string>.Ok 3)
244244
"""
245245

246+
247+
[<Test>]
248+
let ``Overloading on System.Nullable and Result produces a builtin conversion warning when Nullable is picked``() =
249+
CompilerAssert.TypeCheckSingleErrorWithOptions
250+
[| "--warnon:3389" |]
251+
"""
252+
module Test
253+
254+
type M() =
255+
static member A(n: System.Nullable<int>) = ()
256+
static member A(r: Result<'T, 'TError>) = ()
257+
258+
let test() =
259+
M.A(3)
260+
"""
261+
FSharpDiagnosticSeverity.Warning
262+
3389
263+
(9, 9, 9, 10)
264+
"""This expression uses a built-in implicit conversion to convert type 'int' to type 'System.Nullable<int>'. See https://aka.ms/fsharp-implicit-convs."""
265+
246266
[<Test>]
247267
let ``Overloading on System.Nullable<int>, System.Nullable<'T> and int all work without error``() =
248268
CompilerAssert.RunScript
@@ -403,7 +423,7 @@ let test() =
403423
]))
404424

405425
[<Test>]
406-
let ``Test retrieving an argument set in nested method call property setter works``() =
426+
let ``Test retrieving an argument provided in a nested method call property setter works``() =
407427
CompilerAssert.RunScript
408428
"""
409429
type Input<'T>(v: 'T) =

0 commit comments

Comments
 (0)