Skip to content

Commit 24c8d84

Browse files
committed
[Parser] Gate 'repeat' parsing for variadic generics behind the experimental
feature flag to preserve existing parser diagnostics until the feature is official.
1 parent c257672 commit 24c8d84

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

lib/Parse/ParseExpr.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -512,7 +512,8 @@ ParserResult<Expr> Parser::parseExprUnary(Diag<> Message, bool isExprBasic) {
512512
tryLexRegexLiteral(/*forUnappliedOperator*/ false);
513513

514514
// 'repeat' as an expression prefix is a pack expansion expression.
515-
if (Tok.is(tok::kw_repeat)) {
515+
if (Context.LangOpts.hasFeature(Feature::VariadicGenerics) &&
516+
Tok.is(tok::kw_repeat)) {
516517
SourceLoc repeatLoc = consumeToken();
517518
auto patternExpr = parseExpr(Message);
518519
if (patternExpr.isNull())

lib/Parse/ParseStmt.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,8 @@ bool Parser::isStartOfStmt() {
6666
// is a pack expansion expression.
6767
// FIXME: 'repeat' followed by '{' could be a pack expansion
6868
// with a closure pattern.
69-
return peekToken().is(tok::l_brace);
69+
return !Context.LangOpts.hasFeature(Feature::VariadicGenerics) ||
70+
peekToken().is(tok::l_brace);
7071

7172
case tok::pound_line:
7273
// #line at the start of a line is a directive, when within, it is an expr.

0 commit comments

Comments
 (0)