mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
[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:
@@ -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) &&
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user