-
Notifications
You must be signed in to change notification settings - Fork 81
Description
Describe the bug
The documentation states that
I is a V box that indents every line in the output with is spaces
However, format(I([V([...]))) does not equal format(I([...])), even when setting is=0 on some boxes.
Investigating further, I am surprised by the formatting of I on itself, which does not seem to be formatted like a V at all.
rascal>format(V([L("a"), L("b")]))
str: "a\nb\n"
───
a
b
───
rascal>format(I([L("a"), L("b")]))
str: " a b\n"
───
a b
───
rascal>format(I([L("a"), L("b")], vs=1))
str: " a b\n"
───
a b
───To Reproduce
Some tests showcasing this behaviour (I think only one of IisVsugar{1,2} might be correct).
test bool iProducesNewline() =
contains(format(I([L("a"), L("b")])), "a\n");
test bool IisVsugar1() =
format(
I([
V([
L("a"),
L("b")
])
])
) == format(
I([
L("a"),
L("b")
])
);
test bool IisVsugar2() =
format(
I([
V([
L("a"),
L("b")
], is=0)
])
) == format(
I([
L("a"),
L("b")
])
);Expected behavior
Equal formatting, and/or a clarification in the documentation of when exactly (for what parameters) this is (not) the case.
Desktop (please complete the following information):
- Context: standard library
- Rascal Version: `0.41.0-RC55-SNAPSHOT
Additional context
This came up while experimenting with a box-based formatter for Pico (usethesource/rascal-language-servers#677). Currently, this code is probably not used by many people. Once we expose formatting for DSLs, this behaviour might start to occur for more users.