@@ -171,14 +171,14 @@ bool Parser::startsParameterName(bool isClosure) {
171171 !Tok.is (tok::kw_repeat))
172172 return true ;
173173
174- // "isolated" can be an argument label, but it's also a contextual keyword,
175- // so look ahead one more token (two total) see if we have a ':' that would
174+ // Parameter specifiers can be an argument label, but they're also
175+ // contextual keywords, so look ahead one more token (two total) and see
176+ // if we have a ':' that would
176177 // indicate that this is an argument label.
177178 return lookahead<bool >(2 , [&](CancellableBacktrackingScope &) {
178179 if (Tok.is (tok::colon))
179180 return true ; // isolated :
180181
181- // isolated x :
182182 return Tok.canBeArgumentLabel () && nextTok.is (tok::colon);
183183 });
184184 }
@@ -262,6 +262,17 @@ Parser::parseParameterClause(SourceLoc &leftParenLoc,
262262 || Tok.isContextualKeyword (" consuming" )
263263 || Tok.isContextualKeyword (" isolated" )
264264 || Tok.isContextualKeyword (" _const" )))) {
265+ // is this token the identifier of an argument label?
266+ bool partOfArgumentLabel = lookahead<bool >(1 , [&](CancellableBacktrackingScope &) {
267+ if (Tok.is (tok::colon))
268+ return true ; // isolated :
269+
270+ return Tok.canBeArgumentLabel () && peekToken ().is (tok::colon);
271+ });
272+
273+ if (partOfArgumentLabel)
274+ break ;
275+
265276 if (Tok.isContextualKeyword (" isolated" )) {
266277 // did we already find an 'isolated' type modifier?
267278 if (param.IsolatedLoc .isValid ()) {
@@ -271,18 +282,6 @@ Parser::parseParameterClause(SourceLoc &leftParenLoc,
271282 continue ;
272283 }
273284
274- // is this 'isolated' token the identifier of an argument label?
275- bool partOfArgumentLabel = lookahead<bool >(1 , [&](CancellableBacktrackingScope &) {
276- if (Tok.is (tok::colon))
277- return true ; // isolated :
278-
279- // isolated x :
280- return Tok.canBeArgumentLabel () && peekToken ().is (tok::colon);
281- });
282-
283- if (partOfArgumentLabel)
284- break ;
285-
286285 // consume 'isolated' as type modifier
287286 param.IsolatedLoc = consumeToken ();
288287 continue ;
0 commit comments