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

with rewrite leaves empty with block behind in certain situations #184

Closed
JesseHerrick opened this issue Jul 10, 2024 · 2 comments
Closed

Comments

@JesseHerrick
Copy link

Hello! 👋 Thanks for this awesome Elixir tool! We encountered an interesting bug while applying Styler to our codebase. It seems that in certain situations, Styler leaves behind an empty with block wrapping the result.

I plan on looking into this myself when I have a bit of time, but I figured creating the issue would be helpful for tracking in any case.

Versions

  • Elixir: 1.16.0 and 1.17.2
  • Styler: Latest commit c16d3a91e489d043738e2b3bf5c12b6e6357e80c

Example Input

This test case can replicate the issue:

test "bug in with rewrite" do
  assert_style(
    """
    with foo <- do_stuff(value),
         {:ok, result} <- do_more_stuff(bar, baz) do
      {:ok, result}
    end
    """,
    """
    foo = do_stuff(value)
    do_more_stuff(bar, baz)
    """
  )
end

Stacktrace / Current Behaviour

     Styling produced unexpected results
     expected:
       foo = do_stuff(value)
       do_more_stuff(bar, baz)
     styled:
       foo = do_stuff(value)

       with do
         do_more_stuff(bar, baz)
       end
@novaugust
Copy link
Contributor

thanks so much for the issue + repro!

@JesseHerrick
Copy link
Author

Thank you very much for the fix!

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

2 participants