Reproducer
With JuliaFormatter's SciMLStyle, a macro call with a do block whose arguments wrap over multiple lines produces unindented do arguments:
using JuliaFormatter
src = """
expr_spec = @template_spec(parameters=(p1=10, p2=10, p3=1), expressions=(f, g)) do x1,
x2,
class
x1 * 2
end
"""
print(format_text(src; style=SciMLStyle(), margin=92))
On JuliaFormatter v2.10.1 this gives:
expr_spec = @template_spec(parameters=(p1 = 10, p2 = 10, p3 = 1), expressions=(f, g)
) do x1,
x2,
class
x1 * 2
end
The surprising part is that the continuation arguments after do x1, are at column 1, which looks accidental/unstable and is hard to read.
For comparison, BlueStyle formats the same snippet as:
expr_spec = @template_spec(
parameters=(p1=10, p2=10, p3=1), expressions=(f, g)
) do x1, x2, class
x1 * 2
end
and YASStyle indents the wrapped do arguments under the first argument.
Version notes
I checked a small matrix on Julia 1.12.5:
- v1.0.55 through v2.4.0: already put
x2, and class at column 1 for this SciMLStyle example.
- v2.5.0/v2.6.0: output changed further and preserved the original double spaces around the macro-call /
do, and also produced x1*2 in the body.
- v2.6.15 through v2.10.1: spaces in the body are fixed again, but the unindented multiline
do arguments remain; the closing ) before do also ends up on its own line for this case.
So the unindented do-argument behavior is not a brand-new v2.10 regression, but the macro-call formatting around this case did change noticeably between v2.4.0 and v2.5.0.
Expected
I would expect the continuation arguments to either stay on one line when they fit:
or, if split, to be indented consistently, e.g.
Thanks!
Reproducer
With JuliaFormatter's
SciMLStyle, a macro call with adoblock whose arguments wrap over multiple lines produces unindenteddoarguments:On JuliaFormatter v2.10.1 this gives:
The surprising part is that the continuation arguments after
do x1,are at column 1, which looks accidental/unstable and is hard to read.For comparison,
BlueStyleformats the same snippet as:and
YASStyleindents the wrappeddoarguments under the first argument.Version notes
I checked a small matrix on Julia 1.12.5:
x2,andclassat column 1 for this SciMLStyle example.do, and also producedx1*2in the body.doarguments remain; the closing)beforedoalso ends up on its own line for this case.So the unindented
do-argument behavior is not a brand-new v2.10 regression, but the macro-call formatting around this case did change noticeably between v2.4.0 and v2.5.0.Expected
I would expect the continuation arguments to either stay on one line when they fit:
) do x1, x2, classor, if split, to be indented consistently, e.g.
) do x1, x2, classThanks!