[SE-0458] Disambiguate "unsafe" expression within string interpolation

String interpolation uses an end-of-file token, which we weren't
checking for. Fixes rdar://146493296
This commit is contained in:
Doug Gregor
2025-03-07 15:07:45 -08:00
parent 6cf56e9eb7
commit b9cb5ce791
2 changed files with 3 additions and 1 deletions

View File

@@ -439,7 +439,7 @@ ParserResult<Expr> Parser::parseExprSequenceElement(Diag<> message,
if (Tok.isContextualKeyword("unsafe") &&
!(peekToken().isAtStartOfLine() ||
peekToken().isAny(tok::r_paren, tok::r_brace, tok::r_square,
tok::equal, tok::colon, tok::comma) ||
tok::equal, tok::colon, tok::comma, tok::eof) ||
(isExprBasic && peekToken().is(tok::l_brace)) ||
peekToken().is(tok::period) ||
(peekToken().isAny(tok::l_paren, tok::l_square) &&

View File

@@ -207,6 +207,8 @@ func moreUnsafeFunc(unsafe: [Int]) {
// expected-warning@-1{{no unsafe operations occur within 'unsafe' expression}}
_ = unsafe[1]
_ = "\(unsafe)"
}
func yetMoreUnsafeFunc(unsafe: () -> Void) {