Skip to content

Confusing error message for invalid member declaration #920

Closed

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.

Activity

  1. added
    Impact-Low(Internal MS Team use only) Describes an issue with limited impact on existing code.
    on Feb 7, 2016
  2. added and removed
    Impact-Low(Internal MS Team use only) Describes an issue with limited impact on existing code.
    on Feb 2, 2017
  3. dsyme commented on Feb 2, 2017

    @dsyme
    Contributor

    @isaacabraham Please add to your improved error messages catalog? thanks

  4. added this to the milestone on Feb 2, 2017
  5. removed this from the milestone on Jun 9, 2018
  6. added this to the Unknown milestone on Aug 25, 2018
  7. dragonbg commented on May 10, 2020

    @dragonbg
  8. Happypig375 commented on May 10, 2020

    @Happypig375
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions