Skip to content

Missing optional access modifier after equals sign in record syntax #14564

@TysonMN

Description

@TysonMN

The Syntax section says the syntax for a record is

[ attributes ]
type [accessibility-modifier] typename =
    { [ mutable ] label1 : type1;
      [ mutable ] label2 : type2;
      ... }
    [ member-list ]

However, there is something missing. It is also possible to put an access modifier after the equals sign (=). For example, this code compiles

type Foo = private { bar: int }

For what it is worth, here is one way (in terms of where to put white space in the syntax documentation) to express this

[ attributes ]
type [accessibility-modifier] typename = [accessibility-modifier] {
    [ mutable ] label1 : type1;
    [ mutable ] label2 : type2;
    ...
  }
  [ member-list ]

It is not my intention to change the formatting so much compared to the current syntax. I am still trying to learn what F#'s whitespace requirements are, and this is closest syntax to the current form that I know how to do while also including the missing access modifier.

Edit

I found a syntax that adds this additional access modifier and more closely maintains the existing syntax. Other than adding the additional access modifier, the change is indenting everything that comes after the additional access modifier.

[ attributes ]
type [accessibility-modifier] typename =
    [accessibility-modifier]
        { [ mutable ] label1 : type1;
          [ mutable ] label2 : type2;
          ... }
        [ member-list ]

Document Details

Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions