From 570fbf843b5aba3cd5c3894d5a5e35d5b7a3b50a Mon Sep 17 00:00:00 2001 From: bashir Date: Tue, 30 Dec 2025 22:05:11 +0200 Subject: [PATCH] [Lexer] Close comment on //*/ instead of opening a nested one --- lib/Parse/Lexer.cpp | 2 ++ test/Parse/slash_star_comment.swift | 10 ++++++++++ 2 files changed, 12 insertions(+) create mode 100644 test/Parse/slash_star_comment.swift diff --git a/lib/Parse/Lexer.cpp b/lib/Parse/Lexer.cpp index d9f3c70ffddc9..f6806cf151c13 100644 --- a/lib/Parse/Lexer.cpp +++ b/lib/Parse/Lexer.cpp @@ -452,6 +452,8 @@ static bool skipToEndOfSlashStarComment(const char *&CurPtr, case '/': // Check for a '/*' if (*CurPtr == '*') { + if (CurPtr[1] == '/') + continue; ++CurPtr; ++Depth; } diff --git a/test/Parse/slash_star_comment.swift b/test/Parse/slash_star_comment.swift new file mode 100644 index 0000000000000..bd10a2c20cd10 --- /dev/null +++ b/test/Parse/slash_star_comment.swift @@ -0,0 +1,10 @@ +// RUN: %target-typecheck-verify-swift + +// https://github.com/swiftlang/swift/issues/44163 + +/* +//*/ +print("wat") + +/*/ comment /*/ +print("ok")