Skip to content

Commit b3a4ab6

Browse files
committed
Revert removal of invalid interpolation check
1 parent a7d33aa commit b3a4ab6

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

lib/Parse/ParseExpr.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2064,6 +2064,15 @@ ParserResult<Expr> Parser::parseExprStringLiteral() {
20642064

20652065
return makeParserResult(createStringLiteralExprFromSegment(Context, L, Segments.front(), Loc));
20662066
}
2067+
2068+
// We're not in a place where an interpolation would be valid.
2069+
if (!CurLocalContext) {
2070+
// Return an error, but include an empty InterpolatedStringLiteralExpr
2071+
// so that parseDeclPoundDiagnostic() can figure out why this string
2072+
// literal was bad.
2073+
return makeParserErrorResult(
2074+
new (Context) InterpolatedStringLiteralExpr(Loc, 0, 0, nullptr));
2075+
}
20672076

20682077
unsigned LiteralCapacity = 0;
20692078
unsigned InterpolationCount = 0;

0 commit comments

Comments
 (0)