Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
55 commits
Select commit Hold shift + click to select a range
9e37b2c
Add regression test for #6750: Mutually recursive DU values initializ…
T-Gro Mar 24, 2026
1cd0ca0
Add regression tests for #14308 and #14310: Signature generation impr…
T-Gro Mar 24, 2026
5ee6d09
Add regression test for #16410: no spurious FS3570 with KeyValue acti…
T-Gro Mar 24, 2026
632a0ab
Add regression test for #3841: Hash directive indentation in nested m…
T-Gro Mar 24, 2026
fb1ca7e
Add regression test for #14152: nowarn directive before module declar…
T-Gro Mar 25, 2026
0db49dd
Add regression test: #6929, Literal bindings preserve units of measur…
T-Gro Mar 25, 2026
251aaf2
Add regression test: #3660, array of functions invocation correctness…
T-Gro Mar 25, 2026
a02a655
Infra: Update gh aw (#19495)
T-Gro Mar 26, 2026
880dda8
Fix CLIEvent properties to be recognized as events in Symbol API (#18…
Copilot Mar 26, 2026
2292274
Add regression test: #12067, signature generation preserves FSharp. p…
T-Gro Mar 26, 2026
f647072
Add regression test for #11331: accessibility error for internal type…
T-Gro Mar 26, 2026
1dafcf3
Add regression test for #14216: No FS2303 warning for DU in FSI (#19465)
T-Gro Mar 26, 2026
cbab748
Add regression test for #13697: typeof in attribute should report FS0…
T-Gro Mar 26, 2026
01fe483
Add regression test for #9382: SRTP stress test with matrix inverse (…
T-Gro Mar 26, 2026
a21c12f
Add regression test: #12023, FSI can load System.Drawing.Common via n…
T-Gro Mar 26, 2026
63294d7
Add documentation and tests that maxBy/minBy return the first max/min…
Copilot Mar 27, 2026
0b80769
Bugfix :: Fix type definition metadata: duplicate methods, event flag…
T-Gro Mar 27, 2026
a0cce49
resolve integrity issues in gh aw (#19510)
T-Gro Mar 27, 2026
0c868a5
Add Regression PR Shepherd workflow (#19500)
T-Gro Mar 30, 2026
2adf45d
Improve repo-assist: regression test verification, windows-only revis…
T-Gro Mar 30, 2026
bf62ec0
Update dependencies from https://github.com/dotnet/arcade build 20260…
dotnet-maestro[bot] Mar 30, 2026
df38aef
[main] Update dependencies from dotnet/msbuild (#19493)
dotnet-maestro[bot] Mar 30, 2026
358d088
Add regression test for #3532: FSharpEntity.IsByRef is false for byre…
T-Gro Mar 30, 2026
3ee2a3e
Add regression test for #15655: error codes 999 and 3217 are distinct…
T-Gro Mar 30, 2026
f540da5
Add regression test: #13519, C# optional parameters from F# (#19473)
T-Gro Mar 30, 2026
68fb63d
Add regression test: #6648, DU of DUs with inline static members (#19…
T-Gro Mar 31, 2026
f3b6407
Fix repo-assist: add safe output discipline and iteration limits (#19…
Copilot Mar 31, 2026
7d031d3
Update dependencies from https://github.com/dotnet/msbuild build 2026…
dotnet-maestro[bot] Mar 31, 2026
b0bb2f0
Update dependencies from https://dev.azure.com/dnceng/internal/_git/d…
dotnet-maestro[bot] Mar 31, 2026
8254128
Add aw-auto-update workflow + upgrade to v0.64.4 (#19519)
T-Gro Mar 31, 2026
1775f42
Add regression test for #6715: land is a valid identifier (#19478)
T-Gro Mar 31, 2026
4e25902
[main] Update dependencies from dotnet/roslyn (#19494)
dotnet-maestro[bot] Apr 1, 2026
4b57615
Add regression test: #15987, SRTP overload resolution returns correct…
github-actions[bot] Apr 1, 2026
af3a8eb
Add regression test: #15070, hash-load with dot-slash prefix no longe…
github-actions[bot] Apr 1, 2026
7e0ab7a
Add regression test: #16056, auto property DeclarationLocation correc…
github-actions[bot] Apr 1, 2026
af6c784
Add regression test: #19456, nested let bang in plain let inside task…
github-actions[bot] Apr 1, 2026
02b1081
Add regression test: #16007, SRTP ctor constraint no longer causes va…
github-actions[bot] Apr 1, 2026
9b016f5
Add regression test: #7177, never-matched warning with active pattern…
github-actions[bot] Apr 1, 2026
7580b31
Tests: prevent in-proc fsi from killing test host with "exit" (#19407)
majocha Apr 1, 2026
3550f3c
Add regression test: #9878, SRTP with phantom type parameter (#19467)
T-Gro Apr 1, 2026
6a5df48
Fix FS0452 for empty string pattern matching in quotations (#19532)
Copilot Apr 1, 2026
599a99f
Fix regression-pr-shepherd: bound PR processing per run to prevent co…
Copilot Apr 1, 2026
d507366
Make fsharp-diagnostics skill a directive, not a suggestion (#19520)
T-Gro Apr 1, 2026
d85a74c
Update agentic workflows to v0.67.2 and fix merge conflict (#19556)
T-Gro Apr 8, 2026
6f0e1ed
Fix Regression PR Shepherd: restrict push scope and strengthen PR sel…
Copilot Apr 9, 2026
1f46886
[main] Source code updates from dotnet/dotnet (#19546)
dotnet-maestro[bot] Apr 9, 2026
a88269a
[main] Update dependencies from dotnet/roslyn (#19544)
dotnet-maestro[bot] Apr 10, 2026
85d7cb1
[main] Update dependencies from dotnet/msbuild (#19543)
dotnet-maestro[bot] Apr 10, 2026
0539af7
Add regression test: #16154, task CE with IQueryable filters no longe…
github-actions[bot] Apr 10, 2026
ead77d1
[main] Update dependencies from dotnet/arcade (#19542)
dotnet-maestro[bot] Apr 10, 2026
98c4774
Add regression tests for #10043: backtick, @, and ! in type annotatio…
T-Gro Apr 10, 2026
5bcca43
Fix wrong warning 20 range in sequential expressions (#5735) (#19504)
Copilot Apr 11, 2026
bd2823e
Fix completion inconsistently filtering obsolete fields and events (#…
Copilot Apr 11, 2026
f1b1a57
Map this branch to rel/insiders, set VSMinorVersion=7
abonie May 6, 2026
dba9a97
Merge branch 'release/dev18.6' into release/dev18.6
abonie May 7, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fix wrong warning 20 range in sequential expressions (#5735) (#19504)
In TcStmt, the range used for warning 20 was synExpr.Range which, for
sequential expressions (e.g. loop bodies with multiple statements),
covered the entire body. This made the squiggle highlight the whole
block instead of just the offending non-unit expression.

Added lastExprRange helper that walks the SynExpr.Sequential chain to
find the range of the last expression, so the warning now correctly
points at only the expression that produces the ignored value.

Added 4 regression tests for for-in, for-to, and while loops.

Co-authored-by: Tomas Grosup <tomasgrosup@microsoft.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
  • Loading branch information
3 people authored Apr 11, 2026
commit 5bcca434c6272b4e133c311a42e1eaf755a66e91
1 change: 1 addition & 0 deletions docs/release-notes/.FSharp.Compiler.Service/11.0.100.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
* 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 DefaultAugmentation(false) duplicate entry in method table. (Issue [#16565](https://github.com/dotnet/fsharp/issues/16565), [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))
* 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))
* 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))
* 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))
* 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))
Expand Down
11 changes: 10 additions & 1 deletion src/Compiler/Checking/Expressions/CheckExpressions.fs
Original file line number Diff line number Diff line change
Expand Up @@ -5522,7 +5522,16 @@ and TcStmtThatCantBeCtorBody (cenv: cenv) env tpenv synExpr =
and TcStmt (cenv: cenv) env tpenv synExpr =
let g = cenv.g
let expr, ty, tpenv = TcExprOfUnknownType cenv env tpenv synExpr
let m = synExpr.Range

// Use the range of the last expression in a sequential chain for warnings,
// so that "expression is ignored" diagnostics point at the offending expression
// rather than the entire sequential body. See https://github.com/dotnet/fsharp/issues/5735
let rec lastExprRange (e: SynExpr) =
match e with
| SynExpr.Sequential(expr2 = expr2) -> lastExprRange expr2
| _ -> e.Range

let m = lastExprRange synExpr
let wasUnit = UnifyUnitType cenv env m ty expr
if wasUnit then
expr, tpenv
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,63 @@ while x < 1 do
|> withSingleDiagnostic (Warning 20, Line 6, Col 5, Line 6, Col 9,
"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'.")

// https://github.com/dotnet/fsharp/issues/5735
[<Fact>]
let ``Warn On Last Expression In For Loop - int``() =
FSharp """
module ClassLibrary17

for i in 1 .. 10 do
printfn ""
printfn "" |> ignore
123
"""
|> typecheck
|> shouldFail
|> withSingleDiagnostic (Warning 20, Line 7, Col 5, Line 7, Col 8,
"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'.")

// https://github.com/dotnet/fsharp/issues/5735
[<Fact>]
let ``Warn On Last Expression In For Loop - string``() =
FSharp """
for i in 1 .. 10 do
printfn ""
"hello"
"""
|> typecheck
|> shouldFail
|> withSingleDiagnostic (Warning 20, Line 4, Col 5, Line 4, Col 12,
"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'.")

// https://github.com/dotnet/fsharp/issues/5735
[<Fact>]
let ``Warn On Last Expression In Integer For Loop``() =
FSharp """
for i = 1 to 10 do
printfn ""
42
"""
|> typecheck
|> shouldFail
|> withSingleDiagnostic (Warning 20, Line 4, Col 5, Line 4, Col 7,
"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'.")

// https://github.com/dotnet/fsharp/issues/5735
[<Fact>]
let ``Warn On Last Expression In While Loop - non-bool``() =
FSharp """
let mutable x = 0
while x < 1 do
printfn "unneeded"
x <- x + 1
123
"""
|> typecheck
|> shouldFail
|> withSingleDiagnostic (Warning 20, Line 6, Col 5, Line 6, Col 8,
"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'.")

[<Fact>]
let ``Warn If Possible Property Setter``() =
FSharp """
Expand Down
Loading