Skip to content

Commit ebbc9c8

Browse files
committed
[SyntaxParse] Don't update PreviousLoc when ignoring token.
So that the last token in Syntax and PreviousLoc match.
1 parent bb08667 commit ebbc9c8

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

lib/Parse/Parser.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -755,6 +755,7 @@ void Parser::skipSingle() {
755755
}
756756

757757
void Parser::ignoreToken() {
758+
assert(!Tok.is(tok::eof) && "Lexing eof token");
758759
ParsedTriviaList Skipped;
759760
Skipped.reserve(LeadingTrivia.size() + TrailingTrivia.size() + 1 + 2);
760761
std::move(LeadingTrivia.begin(), LeadingTrivia.end(),
@@ -764,7 +765,7 @@ void Parser::ignoreToken() {
764765
std::back_inserter(Skipped));
765766

766767
TokReceiver->receive(Tok);
767-
consumeTokenWithoutFeedingReceiver();
768+
L->lex(Tok, LeadingTrivia, TrailingTrivia);
768769

769770
std::move(LeadingTrivia.begin(), LeadingTrivia.end(),
770771
std::back_inserter(Skipped));

test/Parse/recovery.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -511,7 +511,7 @@ struct ErrorInFunctionSignatureResultArrayType5 {
511511

512512

513513
struct ErrorInFunctionSignatureResultArrayType11 { // expected-note{{in declaration of 'ErrorInFunctionSignatureResultArrayType11'}}
514-
func foo() -> Int[(a){a++}] { // expected-error {{consecutive declarations on a line must be separated by ';'}} {{21-21=;}} expected-error {{expected ']' in array type}} expected-note {{to match this opening '['}} expected-error {{expected '{' in body of function declaration}} expected-error {{expected declaration}}
514+
func foo() -> Int[(a){a++}] { // expected-error {{consecutive declarations on a line must be separated by ';'}} {{20-20=;}} expected-error {{expected ']' in array type}} expected-note {{to match this opening '['}} expected-error {{expected '{' in body of function declaration}} expected-error {{expected declaration}}
515515
}
516516
}
517517

0 commit comments

Comments
 (0)