Skip to content

Commit 4b6e56d

Browse files
authored
Merge pull request #40684 from etcwilde/ewilde/an-actor-for-your-thoughts
Fix miss-parse diagnostic to say "actor"
2 parents d131c37 + 68b9fe8 commit 4b6e56d

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
@@ -7757,8 +7757,10 @@ ParserResult<ClassDecl> Parser::parseDeclClass(ParseDeclOptions Flags,
77577757
{
77587758
// Parse the body.
77597759
if (parseMemberDeclList(LBLoc, RBLoc,
7760-
diag::expected_lbrace_class,
7761-
diag::expected_rbrace_class,
7760+
isExplicitActorDecl ? diag::expected_lbrace_actor
7761+
: diag::expected_lbrace_class,
7762+
isExplicitActorDecl ? diag::expected_rbrace_actor
7763+
: diag::expected_rbrace_class,
77627764
CD))
77637765
Status.setIsParseError();
77647766
}

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)