Skip to content

Commit b9cb5ce

Browse files
committed
[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
1 parent 6cf56e9 commit b9cb5ce

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

lib/Parse/ParseExpr.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -439,7 +439,7 @@ ParserResult<Expr> Parser::parseExprSequenceElement(Diag<> message,
439439
if (Tok.isContextualKeyword("unsafe") &&
440440
!(peekToken().isAtStartOfLine() ||
441441
peekToken().isAny(tok::r_paren, tok::r_brace, tok::r_square,
442-
tok::equal, tok::colon, tok::comma) ||
442+
tok::equal, tok::colon, tok::comma, tok::eof) ||
443443
(isExprBasic && peekToken().is(tok::l_brace)) ||
444444
peekToken().is(tok::period) ||
445445
(peekToken().isAny(tok::l_paren, tok::l_square) &&

test/Unsafe/safe.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,8 @@ func moreUnsafeFunc(unsafe: [Int]) {
207207
// expected-warning@-1{{no unsafe operations occur within 'unsafe' expression}}
208208

209209
_ = unsafe[1]
210+
211+
_ = "\(unsafe)"
210212
}
211213

212214
func yetMoreUnsafeFunc(unsafe: () -> Void) {

0 commit comments

Comments
 (0)