dotnet / dotnet/fsharp

Specific indentation of type constraint throws error

Open
#6,938 5 comments 0 reactions 1 assignee Claimed by @edgarfgp View on GitHub
Feature Request Needs-RFC
Dominant language
F#
Stars
4.3k
Forks
876
Avg merge
4d 11h
Merged PRs (30d)
131

Description

When the `when` in a type constraint is directly under the apostrophe of the generic type, it throws a compiler error. If the type constraint is one space to the left or one space to the right it compiles successfully.

**Repro steps**

Compile the following:

```fsharp
type A<'T
when 'T : comparison>() = // this is fine
class end

type B<'T
when 'T : comparison>() = // this is fine
class end

type C<'T
when 'T : comparison>() = // error
class end
```

Note that in `A` the `when` starts under the `<`, in `B` the `when` starts under the `T` and in `C` the `when` starts under the `'`

**Expected behavior**

All three cases compile

**Actual behavior**

I get the following error:
```
error FS0010: Incomplete structured construct at or before this point in type name. Expected '>' or other token
```

**Known workarounds**

You can move the indentation of the type constraint forwards or backwards by one space.

**Related information**

* F#: 4.6
* IDE: Visual Studio 2019
* OS: Windows 10

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.