while ... do: inconsistent handling of whitespace / indentation
- Dominant language
- F#
- Stars
- 4.3k
- Forks
- 876
- Avg merge
- 4d 22h
- Merged PRs (30d)
- 144
Description
`while ... do` expressions handle whitespace / indentation in a manner that is not consistent with `if ... then ... else` expressions.
This is problematic when the test expression is lengthy and would be more clearly written using multiple lines, along the lines of:
``` fsharp
while
x > 10
&&
x < 20
do ...
```
**Repro steps**
Provide the steps required to reproduce the problem:
``` fsharp
let mutable x = 0
while
x < 10
do
x <- x + 1
```
**Expected behavior**
I would expect this to be valid syntax, in a fashion similar to
``` fsharp
if
x < 10
then
// do something
else
// do something
```
**Actual behavior**
`error FS0010: Incomplete structured construct at or before this point in expression`
`Missing 'do' in 'while' expression. Expected 'while do '.`
**Known workarounds**
Any indentation of `do` resolves the issue:
``` fsharp
let mutable x = 0
while
x < 10
do
x <- x + 1
```
Contributor guide
Assessment
This issue has not been assessed yet.