I am not sure exactly which test breakage Martin was trying to fix in
r273694. For now, fix the behavior for top-level conditionals, which
(surprisingly) are actually used somewhat commonly.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@275183
91177308-0d34-0410-b5e6-
96231b3b80d8
}
// Declarations cannot be conditional expressions, this can only be part
// of a type declaration.
- if (!Contexts.back().IsExpression &&
+ if (Line.MustBeDeclaration && !Contexts.back().IsExpression &&
Style.Language == FormatStyle::LK_JavaScript)
break;
parseConditional();
TEST_F(FormatTestJS, Conditional) {
verifyFormat("y = x ? 1 : 2;");
- verifyFormat("x ? 1: 2;"); // Known issue with top level conditionals.
+ verifyFormat("x ? 1 : 2;");
verifyFormat("class Foo {\n"
" field = true ? 1 : 2;\n"
" method(a = true ? 1 : 2) {}\n"