Skip to content

Confusing error message for invalid member declaration #920

@svick

Description

@svick

When the name of a member is incorrectly enclosed in parentheses, the error message is confusing.

For example, this code:

type T =
    static member (x) = 0

Causes the error:

Only simple variable patterns can be bound in 'let rec' constructs

This is confusing, because the code above doesn't contain any let rec constructs.

This also happens when a type annotation is included in the parentheses, e.g.:

static member (x:int) = 0

I think a simple way to fix this would be to change the error message in this case to:

Only simple variable patterns can be bound in 'member' constructs

I noticed this when looking at this Stack Overflow question.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions