Skip to content

Commit 319672d

Browse files
authored
Merge pull request swiftlang#40668 from etcwilde/ewilde/an-actor-for-your-thoughts
Fix miss-parse diagnostic to say "actor"
2 parents 340a2b7 + c61ae35 commit 319672d

File tree

3 files changed

+22
-2
lines changed

3 files changed

+22
-2
lines changed

include/swift/AST/DiagnosticsParse.def

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -366,6 +366,12 @@ ERROR(expected_rbrace_class,none,
366366
ERROR(expected_colon_class, PointsToFirstBadToken,
367367
"expected ':' to begin inheritance clause",())
368368

369+
// Actor
370+
ERROR(expected_lbrace_actor,PointsToFirstBadToken,
371+
"expected '{' in actor", ())
372+
ERROR(expected_rbrace_actor,none,
373+
"expected '}' in actor", ())
374+
369375
// Protocol
370376
ERROR(generic_arguments_protocol,PointsToFirstBadToken,
371377
"protocols do not allow generic parameters; use associated types instead",

lib/Parse/ParseDecl.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7771,8 +7771,10 @@ ParserResult<ClassDecl> Parser::parseDeclClass(ParseDeclOptions Flags,
77717771
{
77727772
// Parse the body.
77737773
if (parseMemberDeclList(LBLoc, RBLoc,
7774-
diag::expected_lbrace_class,
7775-
diag::expected_rbrace_class,
7774+
isExplicitActorDecl ? diag::expected_lbrace_actor
7775+
: diag::expected_lbrace_class,
7776+
isExplicitActorDecl ? diag::expected_rbrace_actor
7777+
: diag::expected_rbrace_class,
77767778
CD))
77777779
Status.setIsParseError();
77787780
}

test/Parse/actor.swift

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// RUN: %target-typecheck-verify-swift -disable-availability-checking
2+
3+
// REQUIRES: concurrency
4+
5+
6+
7+
actor MyActor1 // expected-error {{expected '{' in actor}}
8+
9+
actor MyActor2 { // expected-note@:16 {{to match this opening '{'}}
10+
init() {
11+
}
12+
func hello() { } // expected-error@+1 {{expected '}' in actor}}

0 commit comments

Comments
 (0)