Skip to content

Implicit tuple interpolations, take two #17195

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 18, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions lib/Parse/ParseExpr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1905,8 +1905,17 @@ parseStringSegments(SmallVectorImpl<Lexer::StringSegment> &Segments,
}

Status |= E;
if (E.isNonNull()) {
Exprs.push_back(E.get());
if (auto expr = E.getPtrOrNull()) {
if (auto tuple = dyn_cast<TupleExpr>(expr)) {
// This needs to be wrapped in a ParenExpr so it won't be interpreted
// as an argument list.
// FIXME: Do we want to warn/error about any of these cases?
expr = new (Context) ParenExpr(SourceLoc(), tuple, SourceLoc(),
/*hasTrailingClosure=*/false);
expr->setImplicit();
}

Exprs.push_back(expr);

if (!Tok.is(tok::eof)) {
diagnose(Tok, diag::string_interpolation_extra);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// RUN: not --crash %target-swift-frontend %s -emit-ir
// RUN: %target-swift-frontend %s -emit-ir

func foo<U>(_ x: U?) {
_ = "\(anyLabelHere: x)"
Expand Down