Skip to content

Improve error reporting: message when defining record with open brace on separate line #1826

@smoothdeveloper

Description

@smoothdeveloper

what

When defining a record (and being used to brace languages):

type Foo =
{
  bar: int
}

F# yields

A type definition requires one or more members or other declarations. If you intend to define an empty class, struct or interface, then use 'type ... = class end', 'interface end' or 'struct end'.

why

I made a "mistake" of putting { on its own line without indenting it

how

I'd like the compiler to tell me how to fix the record definition:

The record definition is invalid due to erroneous indentation, either put the opening brace on same line as type declaration or make it indented.

Note that for C# and VB.NET users (and even more for Resharper users), they'd expect the editor to be helpful with formatting, if I open { after type Name =, it should probably indent or put the brace back to the type declaration line.

I do get rants from C#/VB.NET developers about how F# editor in VS doesn't format the code while being typed and how it makes F# "unusable".

Related: #1103

Metadata

Metadata

Assignees

No one assigned

    Labels

    Feature ImprovementTheme-Simple-F#A cross-community initiative called "Simple F#", keeping people in the sweet spot of the language.

    Type

    No type

    Projects

    Status

    In Progress

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions