fsharp / fsharp/emacs-fsharp-mode

indentations in computation expressions not working

Open
#300 0 comments 1 reaction 0 assignees View on GitHub
bug help wanted
Dominant language
Emacs Lisp
Stars
215
Forks
65
PR merge metrics
No merged PRs in 30d

Description

### Description

Statements in computation expressions, which should indent the following lines, but do not, include (those I found so far):
- for
- then
- else

They seem to work outside computation expressions.

### Repro steps
1. use emacs in fsharp-mode and type the following (and be amazed by the non-indenting!):
```
module issues

let indent_in_computation_expressions_not_working () =
seq {
for i = 0 to 10 do
if i % 2 = 0
then
yield "even"
else
yield "odd"
}
```
2. in fsi (dotnet fsi): `#load "issues.fs"`
> #load "issue.fs";;
[Loading /home/.../dev/fs/issue.fs]
/home/.../dev/fs/issue.fs(8,9): warning FS0058: Possible incorrect indentation: this token is offside of context started at position (6:9). Try indenting this token further or using standard formatting conventions.
/home/.../dev/fs/issue.fs(8,9): warning FS0058: Possible incorrect indentation: this token is offside of context
started at position (6:9). Try indenting this token further or using standard formatting conventions.

### Expected behavior
The indenting should be right, but it is as shown above.
```
module issues

let indent_in_computation_expressions_not_working () =
seq {
for i = 0 to 10 do
if i % 2 = 0
then
yield "even"
else
yield "odd"
}
```

### Actual behavior
```
module issues

let indent_in_computation_expressions_not_working () =
seq {
for i = 0 to 10 do
if i % 2 = 0
then
yield "even"
else
yield "odd"
}
```

### Known workarounds

use C-c> to indent every line in such a block individually.

### Related information

* Operating system linux
* Branch
* Emacs version GNU Emacs 27.1 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.24, cairo version 1.16.0)
of 2021-03-28, modified by Debian
* .NET Runtime, CoreCLR or Mono Version dotnet --version
5.0.202
* Performance information, links to performance testing scripts

Contributor guide

No contributing guide indexed for this repository

Research direction

Reproduce the provided F# computation-expression example in Emacs with fsharp-mode, then inspect the mode's indentation entry points. Done means that `for`, `then`, and `else` indent their following lines as shown in the expected example, while the resulting file still loads in `dotnet fsi` without indentation warnings.

Written by the indexing model from the issue text.

Assessment

Tech stack
emacs, fsharp
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.