taymonbeal created this revision. taymonbeal added reviewers: MyDeveloperDay, owenpan. Herald added a project: All. taymonbeal requested review of this revision. Herald added a project: clang. Herald added a subscriber: cfe-commits.
These were previously incorrectly treated as syntax errors. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D144317 Files: clang/lib/Format/TokenAnnotator.cpp clang/unittests/Format/FormatTestJS.cpp Index: clang/unittests/Format/FormatTestJS.cpp =================================================================== --- clang/unittests/Format/FormatTestJS.cpp +++ clang/unittests/Format/FormatTestJS.cpp @@ -2822,5 +2822,9 @@ Style); } +TEST_F(FormatTestJS, TupleTypeWithOptionalLastElement) { + verifyFormat("type T = [number?];"); +} + } // namespace format } // end namespace clang Index: clang/lib/Format/TokenAnnotator.cpp =================================================================== --- clang/lib/Format/TokenAnnotator.cpp +++ clang/lib/Format/TokenAnnotator.cpp @@ -1248,7 +1248,7 @@ case tok::question: if (Style.isJavaScript() && Tok->Next && Tok->Next->isOneOf(tok::semi, tok::comma, tok::colon, tok::r_paren, - tok::r_brace)) { + tok::r_brace, tok::r_square)) { // Question marks before semicolons, colons, etc. indicate optional // types (fields, parameters), e.g. // function(x?: string, y?) {...}
Index: clang/unittests/Format/FormatTestJS.cpp =================================================================== --- clang/unittests/Format/FormatTestJS.cpp +++ clang/unittests/Format/FormatTestJS.cpp @@ -2822,5 +2822,9 @@ Style); } +TEST_F(FormatTestJS, TupleTypeWithOptionalLastElement) { + verifyFormat("type T = [number?];"); +} + } // namespace format } // end namespace clang Index: clang/lib/Format/TokenAnnotator.cpp =================================================================== --- clang/lib/Format/TokenAnnotator.cpp +++ clang/lib/Format/TokenAnnotator.cpp @@ -1248,7 +1248,7 @@ case tok::question: if (Style.isJavaScript() && Tok->Next && Tok->Next->isOneOf(tok::semi, tok::comma, tok::colon, tok::r_paren, - tok::r_brace)) { + tok::r_brace, tok::r_square)) { // Question marks before semicolons, colons, etc. indicate optional // types (fields, parameters), e.g. // function(x?: string, y?) {...}
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits