I tried to format following program with crystal tool format
:
foo([1, [2, 3,
4, 5, [6,
7]],
8, 9],
10, 11)
I got the following result:
foo([1, [2, 3,
4, 5, [6,
7]],
8, 9],
10, 11)
I think it should be the following with the current rule as far as I know.
foo([1, [2, 3,
4, 5, [6,
7]],
8, 9],
10, 11)
This also happens for a simple assignment:
x = [1, [2, 3,
4, 5, [6, 7]],
8, 9]
yields:
x = [1, [2, 3,
4, 5, [6, 7]],
8, 9]
Fine cases:
So, it seems fine if it does not end with ]],
:
x = [1, [2],
8, 9, [3, 4, 5],
6, 7]
yields
x = [1, [2],
8, 9, [3, 4, 5],
6, 7]
And,
x = [1, [2, 3,
4, 5, [6, 7]], 11,
8, 9]
yields:
x = [1, [2, 3,
4, 5, [6, 7]], 11,
8, 9]
With Tuple
This also happens for nesting arrays and tuples:
checker = A.new([{'a', [{'b', [{'c'..'e'}]},
{'e', [NodeRef[0, 2],
{'x'}]}]},
{'z', [NodeRef[1, 1]]}],
1, 2)
yields:
checker = A.new([{'a', [{'b', [{'c'..'e'}]},
{'e', [NodeRef[0, 2],
{'x'}]}]},
{'z', [NodeRef[1, 1]]}],
1, 2)
Can this be a bug?
crystal version
Crystal 1.0.0 ()
LLVM: 12.0.1
Default target: x86_64-unknown-linux-gnu
with Add support for LLVM 12 by Blacksmoke16 · Pull Request #10873 · crystal-lang/crystal · GitHub.
I’ll try some newer versions if there are differences.