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

Formatting failure bug with if keyword likely introduced in #7060 #7085

Open
imclerran opened this issue Sep 17, 2024 · 1 comment
Open

Formatting failure bug with if keyword likely introduced in #7060 #7085

imclerran opened this issue Sep 17, 2024 · 1 comment

Comments

@imclerran
Copy link

imclerran commented Sep 17, 2024

Looks like I've found a bug which was likely introduced with the formatting for early return if statements (#7060). I have a case where an assignment using if/then/else causes a formatting failure, and is being formatted with a hanging else in the debug output as though it were an early return:

setModels : Client, List Str -> Client
setModels = \client, models -> 
    modelsOption = if List.isEmpty models 
        then Option.none {}
        else Option.some models
    { client & models: modelsOption }

Causes a format failed bug, but gets formatted as the following in the debug output file:

setModels : Client, List Str -> Client
setModels = \client, models ->
    modelsOption = if
        List.isEmpty models
    then
        Option.none {}
        else

    Option.some models
    { client & models: modelsOption }

However, by moving the if onto a new line, formatting completes correctly. The following:

setModels : Client, List Str -> Client
setModels = \client, models -> 
    modelsOption = 
        if List.isEmpty models 
            then Option.none {}
            else Option.some models
    { client & models: modelsOption }

Formats as:

setModels : Client, List Str -> Client
setModels = \client, models ->
    modelsOption =
        if
            List.isEmpty models
        then
            Option.none {}
            else

        Option.some models
    { client & models: modelsOption }

This formatting still is incorrectly choosing the early return formatting style, even though this is assignment.

@imclerran
Copy link
Author

Link to zulip convo here

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

No branches or pull requests

1 participant