dotnet / dotnet/fsharp

Improve Error Reporting: Multi-line records

Open
#2,800 2 comments 0 reactions 0 assignees View on GitHub
Area-Diagnostics Feature Improvement Theme-Simple-F#
Dominant language
F#
Stars
4.3k
Forks
876
Avg merge
4d 11h
Merged PRs (30d)
131

Description

# What
Multi-line records can be used with or without ending `;`
However, when you don't use `;`, then the offset indentation leads to mysterious errors.

```fsharp
type Person1 = {
FirstName: string
LastName: string
Height: int
}
```

`error FS0010: Unexpected symbol ':' in type definition. Expected '}' or other token.`

and
```fsharp
type Person2 = {
FirstName: string
LastName: string
Height: int
}

let p = {
FirstName = "John"
LastName = "Doe"
Height = 123
}
```

`error FS0001: This expression was expected to have type string but here has type bool`

# Why

As generally F# doesn't need semicolons in line-endings, it's easy to start with more readable code without semicolons. However if you later have large records and try to refactor the code it's painful to detect the errors.

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.