Skip to content

Parens stripped from custom definitions of op_Range and op_RangeStep operators #1842

@stephen-swensen

Description

@stephen-swensen

Issue created from fantomas-online

Code

[<AutoOpen>] //making auto open allows us not to have to fully qualify module properties
module DecompilationTests
open Xunit
open Swensen.Unquote

module TopLevelOpIsolation3 =
    let (..) x y z = Seq.singleton (x + y + z)
    [<Fact>]
    let ``issue 91: op_Range first class syntax for seq return type but arg mismatch`` () =
        <@ (..) 1 2 3 @> |> decompile =! "TopLevelOpIsolation3.(..) 1 2 3"

    let (.. ..) x y z h = Seq.singleton (x + y + z + h)
    [<Fact>]
    let ``issue 91: op_RangeStep first class syntax for seq return type but arg mismatch`` () =
        <@ (.. ..) 1 2 3 4 @> |> decompile =! "TopLevelOpIsolation3.(.. ..) 1 2 3 4"

Result

[<AutoOpen>] //making auto open allows us not to have to fully qualify module properties
module DecompilationTests

open Xunit
open Swensen.Unquote

module TopLevelOpIsolation3 =
    let .. x y z = Seq.singleton (x + y + z)

    [<Fact>]
    let ``issue 91: op_Range first class syntax for seq return type but arg mismatch`` () =
        <@ (..) 1 2 3 @> |> decompile
        =! "TopLevelOpIsolation3.(..) 1 2 3"

    let .. .. x y z h = Seq.singleton (x + y + z + h)

    [<Fact>]
    let ``issue 91: op_RangeStep first class syntax for seq return type but arg mismatch`` () =
        <@ (.. ..) 1 2 3 4 @> |> decompile
        =! "TopLevelOpIsolation3.(.. ..) 1 2 3 4"

Problem description

I encountered this while testing out Fantomas on Unquote. The offending file is https://github.com/SwensenSoftware/unquote/blob/65a387801325d70ec03c16e6da8b58a468cbd2f3/test/UnquoteTests/DecompilationTests.fs which caused the CLI tool to crash with a "Formatted content is not valid F# code" error. I think there may be other issues with this file, but I narrowed down to issues with (..) and (.. ..) for starts with the online tool.

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 at 07/18/2021 11:37:23 - 23cefe5

Default Fantomas configuration

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