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

Failure to reach fixpoint with align_matrix=true #781

Open
kbarros opened this issue Nov 27, 2023 · 2 comments
Open

Failure to reach fixpoint with align_matrix=true #781

kbarros opened this issue Nov 27, 2023 · 2 comments

Comments

@kbarros
Copy link

kbarros commented Nov 27, 2023

The input:

using JuliaFormatter
str = """f([a b
            c d])
         """
format_text(str; style=SciMLStyle(), align_matrix=true)

gives the error:

ERROR: formatted_text hasn't reached to a fixpoint in 4 iterations
Stacktrace:
 [1] error(s::String)
   @ Base ./error.jl:35
 [2] format_text(text::String, style::SciMLStyle; maxiters::Int64, kwargs::@Kwargs{align_matrix::Bool})
   @ JuliaFormatter ~/.julia/packages/JuliaFormatter/ur5KV/src/JuliaFormatter.jl:226
 [3] format_text
   @ JuliaFormatter ~/.julia/packages/JuliaFormatter/ur5KV/src/JuliaFormatter.jl:218 [inlined]
 [4] #format_text#250
   @ JuliaFormatter ~/.julia/packages/JuliaFormatter/ur5KV/src/JuliaFormatter.jl:209 [inlined]
 [5] top-level scope
   @ ~/Desktop/scratch.jl:15

It works, however, with style = BlueStyle().

@domluna
Copy link
Owner

domluna commented Dec 5, 2023

this is because sciml mixes styles at the pretty and nesting stages which it should not do. nesting functions assume the tree was prettified with the same style. so in this case the pretty function uses YAS but then the nest uses Default. If you want this to work turn on yas_style_nesting=true but it might provide other formats you don't want

@kbarros
Copy link
Author

kbarros commented Dec 6, 2023

I was exploring the various possible formatting options, but am not particularly attached to this combination. If sciml style is incompatible with align_*, then perhaps print an error at the level of the call to format_*() to indicate lack of support?

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