Commit e5198db
Fix wrong warning 20 range in sequential expressions (#5735)
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: Copilot <223556219+Copilot@users.noreply.github.com>1 parent 1f46886 commit e5198db
File tree
3 files changed
+68
-1
lines changed- docs/release-notes/.FSharp.Compiler.Service
- src/Compiler/Checking/Expressions
- tests/FSharp.Compiler.ComponentTests/ErrorMessages
3 files changed
+68
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
| 6 | + | |
6 | 7 | | |
7 | 8 | | |
8 | 9 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5522 | 5522 | | |
5523 | 5523 | | |
5524 | 5524 | | |
5525 | | - | |
| 5525 | + | |
| 5526 | + | |
| 5527 | + | |
| 5528 | + | |
| 5529 | + | |
| 5530 | + | |
| 5531 | + | |
| 5532 | + | |
| 5533 | + | |
| 5534 | + | |
5526 | 5535 | | |
5527 | 5536 | | |
5528 | 5537 | | |
| |||
Lines changed: 57 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
176 | 176 | | |
177 | 177 | | |
178 | 178 | | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
179 | 236 | | |
180 | 237 | | |
181 | 238 | | |
| |||
0 commit comments