Skip to content

Support new Interface Static Methods syntax #2500

@nojaf

Description

@nojaf

Issue created from fantomas-online

Code

module CheckNewSyntax

   // Check that "property" and "get_ method" constraints are considered logically equivalent
    let inline f_StaticProperty<'T when 'T : (static member StaticProperty: int) >() : int = 'T.StaticProperty

    let inline f_StaticMethod<'T when 'T : (static member StaticMethod: int -> int) >() : int = 'T.StaticMethod(3)

    let inline f_set_StaticProperty<'T when 'T : (static member StaticProperty: int with set) >() = 'T.set_StaticProperty(3)

    let inline f_InstanceMethod<'T when 'T : (member InstanceMethod: int -> int) >(x: 'T) : int = x.InstanceMethod(3)

    let inline f_Length<'T when 'T : (member Length: int) >(x: 'T) = x.Length

    let inline f_set_Length<'T when 'T : (member Length: int with set) >(x: 'T) = x.set_Length(3)

    let inline f_Item<'T when 'T : (member Item: int -> string with get) >(x: 'T) = x.get_Item(3)

Error

Fantomas.Core.FormatConfig+FormatException: Parsing failed with errors: [{ Severity = Error
   SubCategory = "parse"
   Range = Some tmp.fsx (4,93--4,94)
   ErrorNumber = Some 10
   Message = "Unexpected quote symbol in binding" };
 { Severity = Error
   SubCategory = "parse"
   Range = Some tmp.fsx (6,96--6,97)
   ErrorNumber = Some 10
   Message = "Unexpected quote symbol in binding" };
 { Severity = Error
   SubCategory = "parse"
   Range = Some tmp.fsx (8,100--8,101)
   ErrorNumber = Some 10
   Message = "Unexpected quote symbol in binding" }]
   at Fantomas.Core.CodeFormatterImpl.parse@28.Invoke(Unit unitVar) in /_//src/Fantomas.Core/CodeFormatterImpl.fs:line 33
   at Microsoft.FSharp.Control.AsyncPrimitives.CallThenInvoke[T,TResult](AsyncActivation`1 ctxt, TResult result1, FSharpFunc`2 part2) in D:\a\_work\1\s\src\fsharp\FSharp.Core\async.fs:line 447
   at Microsoft.FSharp.Control.Trampoline.Execute(FSharpFunc`2 firstAction) in D:\a\_work\1\s\src\fsharp\FSharp.Core\async.fs:line 104

Problem description

The changes of dotnet/fsharp#13119 introduced some new syntax. Fantomas needs to be updated in order to deal with this properly.

Extra information

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

Options

Fantomas master branch at 2022-09-11T16:37:09Z - 7fb34e5

Default Fantomas configuration

Did you know that you can ignore files when formatting from fantomas-tool or the FAKE targets by using a .fantomasignore file?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions