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

Parameter after multiline string parameter #783

Closed
nojaf opened this issue Apr 24, 2020 · 0 comments · Fixed by #787
Closed

Parameter after multiline string parameter #783

nojaf opened this issue Apr 24, 2020 · 0 comments · Fixed by #787

Comments

@nojaf
Copy link
Contributor

nojaf commented Apr 24, 2020

Issue created from fantomas-online

Code

let ``match bang`` () =
    formatSourceString false """
async {
    match! myAsyncFunction() with
    | Some x -> printfn "%A" x
    | None -> printfn "Function returned None!"
}"""   config
    |> prepend newline
    |> should equal """
async {
    match! myAsyncFunction () with
    | Some x -> printfn "%A" x
    | None -> printfn "Function returned None!"
}
"""

Result

let ``match bang`` () =
    (formatSourceString false """
async {
    match! myAsyncFunction() with
    | Some x -> printfn "%A" x
    | None -> printfn "Function returned None!"
}""" config)
    |> prepend newline
    |> should equal """
async {
    match! myAsyncFunction () with
    | Some x -> printfn "%A" x
    | None -> printfn "Function returned None!"
}
"""

This code doesn't compile anymore because the config parameter is considered to be part of the following infix expression. Regardless of the parameters.
See https://fsharp.org/specs/language-spec/4.1/FSharpSpec-4.1-latest.pdf#page=91&zoom=auto,-137,286
Page 91 last line.

The suggestion is to add newline if this case occurs:

let ``match bang`` () =
    formatSourceString false """
async {
    match! myAsyncFunction() with
    | Some x -> printfn "%A" x
    | None -> printfn "Function returned None!"
}"""
        config
    |> prepend newline
    |> should equal """
async {
    match! myAsyncFunction () with
    | Some x -> printfn "%A" x
    | None -> printfn "Function returned None!"
}
"""

Options

Fantomas Next - 4.0.0-alpha-001-1/1/1990

Name Value
IndentSpaceNum 4
PageWidth 120
SemicolonAtEndOfLine false
SpaceBeforeParameter true
SpaceBeforeLowercaseInvocation true
SpaceBeforeUppercaseInvocation false
SpaceBeforeClassConstructor false
SpaceBeforeMember false
SpaceBeforeColon false
SpaceAfterComma true
SpaceBeforeSemicolon false
SpaceAfterSemicolon true
IndentOnTryWith false
SpaceAroundDelimiter true
MaxIfThenElseShortWidth 40
MaxInfixOperatorExpression 50
MaxRecordWidth 40
MaxArrayOrListWidth 40
MaxLetBindingWidth 40
MultilineBlockBracketsOnSameColumn false
NewlineBetweenTypeDefinitionAndMembers false
StrictMode false
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant