You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
BEFORE:
main() {
var zero = 0;
if (0 == 0) {
zero=0;
} else if (0 == 1) {
zero=1;
} else if (0 == 2) {
zero =2;
}
print(0);
}
AFTER:
main() {
var zero = 0;
if (0 == 0) {
zero = 0;
} else {
if (0 == 1) {
zero = 1;
} else {
if (0 == 2) {
zero = 2;
}
}
}
print(0);
}
A lot of unnecessary "{}" inserted. Apparently, formatter doesn't think of "else if" as a valid construct, but it is.
Note it's not the same problem as orphans as per issue #16847.
In the latest dev release, orphans produce the same output as above, that is
foo() {
var zero = 0;
if (0 == 0)
zero=0;
else if (0 == 1)
zero=1;
else if (0 == 2)
zero =2;
print(0);
}
is now formatted exactly as in AFTER section above, inserting unnecessary {}. Whereas it was supposed to insert minimal amount of {}, so that the thing after formatting should look as in BEFORE example above.
Another small issue: I had to insert print(0) in the end; without it, formatter prints red error message at the bottom: expected EOF but got '}'
The text was updated successfully, but these errors were encountered:
This issue was originally filed by @tatumizer
BEFORE:
main() {
var zero = 0;
if (0 == 0) {
zero=0;
} else if (0 == 1) {
zero=1;
} else if (0 == 2) {
zero =2;
}
print(0);
}
AFTER:
main() {
var zero = 0;
if (0 == 0) {
zero = 0;
} else {
if (0 == 1) {
zero = 1;
} else {
if (0 == 2) {
zero = 2;
}
}
}
print(0);
}
A lot of unnecessary "{}" inserted. Apparently, formatter doesn't think of "else if" as a valid construct, but it is.
Note it's not the same problem as orphans as per issue #16847.
In the latest dev release, orphans produce the same output as above, that is
foo() {
var zero = 0;
if (0 == 0)
zero=0;
else if (0 == 1)
zero=1;
else if (0 == 2)
zero =2;
print(0);
}
is now formatted exactly as in AFTER section above, inserting unnecessary {}. Whereas it was supposed to insert minimal amount of {}, so that the thing after formatting should look as in BEFORE example above.
Another small issue: I had to insert print(0) in the end; without it, formatter prints red error message at the bottom: expected EOF but got '}'
The text was updated successfully, but these errors were encountered: