Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The 'member' keyword gets deleted in 'abstract member' declarations #1106

Closed
3 tasks
vsinha opened this issue Sep 4, 2020 · 2 comments · Fixed by #1310
Closed
3 tasks

The 'member' keyword gets deleted in 'abstract member' declarations #1106

vsinha opened this issue Sep 4, 2020 · 2 comments · Fixed by #1310
Labels
good first issue Long hanging fruit: easy issue to get your feet wet!

Comments

@vsinha
Copy link

vsinha commented Sep 4, 2020

Issue created from fantomas-online

Code

module Example

type Foo = 
    abstract member bar : int

Result

module Example

type Foo =
    abstract bar: int

Problem description

Member keyword is deleted.

This may be intentional, is that the case?

Extra information

  • The formatted result breaks by code.
  • The formatted result gives compiler warnings.
  • I or my company would be willing to help fix this.

Options

Fantomas 4.0.0-beta-003

Default Fantomas configuration

@nojaf
Copy link
Contributor

nojaf commented Sep 4, 2020

This is a bit historical I think. In short in case of implementation files, it will lead to the same compiled code.
From an AST point of view, these things are exactly the same construct.

Take for example:

module Example

type Foo = 
    abstract member bar : int

type Foo2 = 
    abstract member bar : int
ParsedInput.ImplFile
  (ParsedImplFileInput
     ("tmp.fsx", true, QualifiedNameOfFile Example$fsx, [], [],
      [SynModuleOrNamespace
         ([Example], false, NamedModule,
          [SynModuleDecl.Types
             ([TypeDefn
                 (ComponentInfo
                    ([], [], [], [Foo],
                     PreXmlDoc ((3,8), FSharp.Compiler.XmlDoc+XmlDocCollector),
                     false, None, tmp.fsx (3,5--3,8) IsSynthetic=false),
                  SynTypeDefnRepr.ObjectModel
                    (TyconUnspecified,
                     [SynMemberDefn.AbstractSlot
                        (ValSpfn
                           ([], bar, SynValTyparDecls ([], true, []),
                            SynType.LongIdent (LongIdentWithDots ([int], [])),
                            SynValInfo ([], SynArgInfo ([], false, None)), false,
                            false,
                            PreXmlDoc
                              ((4,19), FSharp.Compiler.XmlDoc+XmlDocCollector),
                            None, None, tmp.fsx (4,4--4,29) IsSynthetic=false),
                         { IsInstance = true
                           IsDispatchSlot = true
                           IsOverrideOrExplicitImpl = false
                           IsFinal = false
                           MemberKind = MemberKind.PropertyGet },
                         tmp.fsx (4,4--4,29) IsSynthetic=false)],
                     tmp.fsx (4,4--4,29) IsSynthetic=false), [],
                  tmp.fsx (3,5--4,29) IsSynthetic=false)],
              tmp.fsx (3,0--4,29) IsSynthetic=false);
           SynModuleDecl.Types
             ([TypeDefn
                 (ComponentInfo
                    ([], [], [], [Foo2],
                     PreXmlDoc ((6,9), FSharp.Compiler.XmlDoc+XmlDocCollector),
                     false, None, tmp.fsx (6,5--6,9) IsSynthetic=false),
                  SynTypeDefnRepr.ObjectModel
                    (TyconUnspecified,
                     [SynMemberDefn.AbstractSlot
                        (ValSpfn
                           ([], bar, SynValTyparDecls ([], true, []),
                            SynType.LongIdent (LongIdentWithDots ([int], [])),
                            SynValInfo ([], SynArgInfo ([], false, None)), false,
                            false,
                            PreXmlDoc
                              ((7,19), FSharp.Compiler.XmlDoc+XmlDocCollector),
                            None, None, tmp.fsx (7,4--7,29) IsSynthetic=false),
                         { IsInstance = true
                           IsDispatchSlot = true
                           IsOverrideOrExplicitImpl = false
                           IsFinal = false
                           MemberKind = MemberKind.PropertyGet },
                         tmp.fsx (7,4--7,29) IsSynthetic=false)],
                     tmp.fsx (7,4--7,29) IsSynthetic=false), [],
                  tmp.fsx (6,5--7,29) IsSynthetic=false)],
              tmp.fsx (6,0--7,29) IsSynthetic=false)],
          PreXmlDoc ((1,6), FSharp.Compiler.XmlDoc+XmlDocCollector), [], None,
          tmp.fsx (1,0--7,29) IsSynthetic=false)], (true, true)))

Notice that both SynMemberDefn.AbstractSlot are identical, so we don't have the information to make the correct call.

Now in case of signature files, this does matter (see #944) and there we have a workaround via the trivia information.

I guess the same trick can be applied here for SynMemberDefn_AbstractSlot.

@nojaf nojaf added the good first issue Long hanging fruit: easy issue to get your feet wet! label Sep 4, 2020
@knocte
Copy link
Contributor

knocte commented Sep 5, 2020

it will lead to the same compiled code.

Then one could argue this is not a bug but a feature?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Long hanging fruit: easy issue to get your feet wet!
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants