Fsharp: Improve error reporting: Missing = on type declaration

Created on 26 Apr 2016  路  4Comments  路  Source: dotnet/fsharp

What

The following error message is generated from this code sample

type Person { Name : string; Age : int; City : string }

error FS0010: Unexpected symbol '{' in type definition. Expected '(' or other token.

Why

The error message suggests to the user that they should put a ( in to fix the problem (or some other unspecified token), when in fact they have missed the = operator. Many other languages allow you to define types without the = sign, so this is not an uncommon issue.

How

Rewrite the above error to something like error FS0010: Unexpected symbol '{' in type definition. Did you forget to use the = operator e.g. "type Person = { Name ..." .

Area-Compiler Feature Improvement

Most helpful comment

All 4 comments

I happen to frequently miss the equal when I defined classes, which breaks intellisense.

I do not do it as much with records or DUs but I think it would be helpful to identify the likely case to have better error messages.

Related #1826

Whoo!

Was this page helpful?
0 / 5 - 0 ratings