Skip to content

Better representation of get/set member #13273

@nojaf

Description

@nojaf

Giving the following code and AST:

type Foo() =
    member this.MyReadWriteProperty
        with get () =   //comment get 
            myInternalValue
        and set (value) =   // comment set
            myInternalValue <- value
SynTypeDefn
   (SynComponentInfo
      ([], None, [], [Foo],
       PreXmlDoc ((2,0), FSharp.Compiler.Xml.XmlDocCollector),
       false, None, tmp.fsx (2,5--2,8)),
    ObjectModel
      (Unspecified,
       [ImplicitCtor
          (None, [], SimplePats ([], tmp.fsx (2,8--2,10)), None,
           PreXmlDoc ((2,8), FSharp.Compiler.Xml.XmlDocCollector),
           tmp.fsx (2,5--2,8));
        Member
          (SynBinding ...
        Member
          (SynBinding ...

It is very confusing that there are two SynMemberDefn.Member created for this in the untyped tree.

Describe the solution you'd like

Could we have a special case in SynMemberDefn that represents this better?
The name SynMemberDefn.ReadWritePropertycomes to mind, but I'm open to suggestions.

Describe alternatives you've considered

Both Members have the same range, so you can hack around it.

Additional context

related: #11481

//cc @dsyme

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions