diff --git a/tests/FSharp.Compiler.ComponentTests/ErrorMessages/WarnExpressionTests.fs b/tests/FSharp.Compiler.ComponentTests/ErrorMessages/WarnExpressionTests.fs index 59b6877698c..214c961741f 100644 --- a/tests/FSharp.Compiler.ComponentTests/ErrorMessages/WarnExpressionTests.fs +++ b/tests/FSharp.Compiler.ComponentTests/ErrorMessages/WarnExpressionTests.fs @@ -284,6 +284,34 @@ while x < 3 do |> withSingleDiagnostic (Warning 20, Line 6, Col 5, Line 6, Col 6, "The result of this expression has type 'int' and is implicitly ignored. Consider using 'ignore' to discard this value explicitly, e.g. 'expr |> ignore', or 'let' to bind the result to a name, e.g. 'let result = expr'.") + [] + let ``Warn On Last Expression Inside async Computation Expression - highlights only offending expression``() = + FSharp """ +let _ = + async { + for _ in [1] do + let x = 1 + x + } + """ + |> typecheck + |> shouldFail + |> withSingleDiagnostic (Warning 20, Line 6, Col 13, Line 6, Col 14, + "The result of this expression has type 'int' and is implicitly ignored. Consider using 'ignore' to discard this value explicitly, e.g. 'expr |> ignore', or 'let' to bind the result to a name, e.g. 'let result = expr'.") + + [] + let ``No Warning 20 For Trailing Non-unit Expression In seq Computation Expression (implicit yield)``() = + FSharp """ +let _ = + seq { + for _ in [1] do + let x = 1 + x + } + """ + |> typecheck + |> shouldSucceed + [] let ``Warn If Possible Property Setter``() = FSharp """