Skip to content

Improve error reporting: property setter in constructor expression #1112

@smoothdeveloper

Description

@smoothdeveloper

What

Sometimes, user wants to assign properties in a constructor expression:

type MyClass() =
    member val MyProperty = "" with get, set

let c = MyClass(Property = "")

gives:

The member or object constructor 'MyClass' has no argument or settable return property 'Property'. The required signature is new : unit -> MyClass.

Why

Given the compiler has exact information about MyClass, it could yield more information about what is possible to do in context of constructor expression.

How

The member or object constructor 'MyClass' has no argument or settable return property 'Property', did you mean to assign 'MyProperty' or (*) instead. The required signature is new : unit -> MyClass.

(*) list X other properties (see discussion) that aren't already listed in the constructor expression in decreasing order of likeliness.
#1103

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions