Skip to content

Commit 82f0260

Browse files
authored
Merge pull request #4049 from rjmccall/invalid-precedencegroup-range
Fix the source range of a precedencegroup declaration that lacks a }
2 parents 819cd0d + 9ade20a commit 82f0260

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

lib/Parse/ParseDecl.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5684,6 +5684,11 @@ Parser::parseDeclPrecedenceGroup(ParseDeclOptions flags,
56845684
return result;
56855685
};
56865686
auto createInvalid = [&] {
5687+
// Use the last consumed token location as the rbrace to satisfy
5688+
// the AST invariant about a decl's source range including all of
5689+
// its components.
5690+
if (!rbraceLoc.isValid()) rbraceLoc = PreviousLoc;
5691+
56875692
auto result = create();
56885693
result->setInvalid();
56895694
return makeParserErrorResult(result);
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// RUN: %target-parse-verify-swift
2+
3+
precedencegroup; // expected-error {{expected identifier}}
4+
5+
precedencegroup A; // expected-error {{expected '{'}}
6+
7+
precedencegroup B {; // expected-error {{expected operator attribute identifier}}

0 commit comments

Comments
 (0)