dotnet / dotnet/fsharp

Different indentation level changes behaviour of the code

Open
#1,019 7 comments 0 reactions 0 assignees View on GitHub
Dominant language
F#
Stars
4.3k
Forks
876
Avg merge
4d 11h
Merged PRs (30d)
131

Description

``` fsharp
let foo t = "(" + t + ")"

let tttt =
let text =
match Some "" with
| Some t ->
match t with
| "" ->
"a"
| "b" ->
"b"
|> foo
| _ -> "fooo"
text

let tttt' =
let text =
match Some "" with
| Some t ->
match t with
| "" ->
"a"
| "b" ->
"b"
|> foo
| _ -> "fooo"
text
```

In `foo` I use two spaces for indentation, in `foo'` four spaces are used.

The resulting expressions are different while I'd had expected those to be the same.

I tried to find something which would explain that in the language specification (which I haven't thoroughly read) but failed, and the behaviour seems to fail me at "principle of least surprise" so submitting this as an issue to get clarification.

Thanks.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.