You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/release-notes/.FSharp.Compiler.Service/11.0.100.md
+1Lines changed: 1 addition & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,6 +3,7 @@
3
3
* Fix DU case names matching IWSAM member names no longer cause duplicate property entries. (Issue [#14321](https://github.com/dotnet/fsharp/issues/14321), [PR #19341](https://github.com/dotnet/fsharp/pull/19341))
* Fix abstract event accessors now have SpecialName flag. (Issue [#5834](https://github.com/dotnet/fsharp/issues/5834), [PR #19341](https://github.com/dotnet/fsharp/pull/19341))
6
+
* Fix warning 20 ("expression is implicitly ignored") pointing at the wrong range when the last expression in a sequential block (e.g. inside `for`, `while` loops) is non-unit. The squiggle now correctly highlights only the offending expression. ([Issue #5735](https://github.com/dotnet/fsharp/issues/5735), [PR #19504](https://github.com/dotnet/fsharp/pull/19504))
6
7
* Fix CLIEvent properties to be correctly recognized as events: `IsEvent` returns `true` and `XmlDocSig` uses `E:` prefix instead of `P:`. ([Issue #10273](https://github.com/dotnet/fsharp/issues/10273), [PR #18584](https://github.com/dotnet/fsharp/pull/18584))
7
8
* Fix extra sequence point at the end of match expressions. ([Issue #12052](https://github.com/dotnet/fsharp/issues/12052), [PR #19278](https://github.com/dotnet/fsharp/pull/19278))
8
9
* Fix wrong sequence point range for `return`/`yield`/`return!`/`yield!` inside computation expressions. ([Issue #19248](https://github.com/dotnet/fsharp/issues/19248), [PR #19278](https://github.com/dotnet/fsharp/pull/19278))
Copy file name to clipboardExpand all lines: tests/FSharp.Compiler.ComponentTests/ErrorMessages/WarnExpressionTests.fs
+57Lines changed: 57 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -176,6 +176,63 @@ while x < 1 do
176
176
|> withSingleDiagnostic (Warning 20, Line 6, Col 5, Line 6, Col 9,
177
177
"The result of this expression has type 'bool' 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'.")
178
178
179
+
// https://github.com/dotnet/fsharp/issues/5735
180
+
[<Fact>]
181
+
let``Warn On Last Expression In For Loop -int``()=
182
+
FSharp """
183
+
module ClassLibrary17
184
+
185
+
for i in 1 .. 10 do
186
+
printfn ""
187
+
printfn "" |> ignore
188
+
123
189
+
"""
190
+
|> typecheck
191
+
|> shouldFail
192
+
|> withSingleDiagnostic (Warning 20, Line 7, Col 5, Line 7, Col 8,
193
+
"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'.")
194
+
195
+
// https://github.com/dotnet/fsharp/issues/5735
196
+
[<Fact>]
197
+
let``Warn On Last Expression In For Loop -string``()=
198
+
FSharp """
199
+
for i in 1 .. 10 do
200
+
printfn ""
201
+
"hello"
202
+
"""
203
+
|> typecheck
204
+
|> shouldFail
205
+
|> withSingleDiagnostic (Warning 20, Line 4, Col 5, Line 4, Col 12,
206
+
"The result of this expression has type 'string' 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'.")
207
+
208
+
// https://github.com/dotnet/fsharp/issues/5735
209
+
[<Fact>]
210
+
let``Warn On Last Expression In Integer For Loop``()=
211
+
FSharp """
212
+
for i = 1 to 10 do
213
+
printfn ""
214
+
42
215
+
"""
216
+
|> typecheck
217
+
|> shouldFail
218
+
|> withSingleDiagnostic (Warning 20, Line 4, Col 5, Line 4, Col 7,
219
+
"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'.")
220
+
221
+
// https://github.com/dotnet/fsharp/issues/5735
222
+
[<Fact>]
223
+
let``Warn On Last Expression In While Loop -non-bool``()=
224
+
FSharp """
225
+
let mutable x = 0
226
+
while x < 1 do
227
+
printfn "unneeded"
228
+
x <- x + 1
229
+
123
230
+
"""
231
+
|> typecheck
232
+
|> shouldFail
233
+
|> withSingleDiagnostic (Warning 20, Line 6, Col 5, Line 6, Col 8,
234
+
"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'.")
0 commit comments