mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
fix <rdar://problem/20167543> "for var x = ..." not parsed as a foreach loop
This was because the ambiguity between c-style and foreach loops wasn't being properly handled. Use the canParsePattern() logic to handle this in full generality. Since that logic was unused, dust it off and clean it up a bit. Similarly, remove some old vestigates of default argument parsing in tuples and old-syntax array handling. Swift SVN r26164
This commit is contained in:
@@ -1110,27 +1110,9 @@ bool Parser::canParsePatternTuple() {
|
||||
|
||||
if (Tok.isNot(tok::r_paren)) {
|
||||
do {
|
||||
// The contextual inout marker is part of argument lists.
|
||||
consumeIf(tok::kw_inout);
|
||||
|
||||
if (!canParsePattern()) return false;
|
||||
|
||||
// Parse default values. This aren't actually allowed, but we recover
|
||||
// better if we skip over them.
|
||||
if (consumeIf(tok::equal)) {
|
||||
while (Tok.isNot(tok::eof) && Tok.isNot(tok::r_paren) &&
|
||||
Tok.isNot(tok::r_brace) && Tok.isNotEllipsis() &&
|
||||
Tok.isNot(tok::comma) &&
|
||||
!isStartOfDecl()) {
|
||||
skipSingle();
|
||||
}
|
||||
}
|
||||
|
||||
} while (consumeIf(tok::comma));
|
||||
}
|
||||
|
||||
if (Tok.isEllipsis())
|
||||
consumeToken();
|
||||
|
||||
return consumeIf(tok::r_paren);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user