Skip to content

Commit 7f158a5

Browse files
authored
Merge pull request swiftlang#17075 from k-enomoto/SR-7844-error-message-for-a-subscript-without-accessors
Fix error message for a subscript without accessors says "computed property"
2 parents c5040a2 + bd92799 commit 7f158a5

File tree

3 files changed

+3
-3
lines changed

3 files changed

+3
-3
lines changed

include/swift/AST/DiagnosticsParse.def

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ ERROR(static_var_decl_global_scope,none,
248248
"%select{%error|static properties|class properties}0 may only be declared on a type",
249249
(StaticSpellingKind))
250250
ERROR(computed_property_no_accessors, none,
251-
"computed property must have accessors specified", ())
251+
"%select{computed property|subscript}0 must have accessors specified", (bool))
252252
ERROR(expected_getset_in_protocol,none,
253253
"expected get or set in a protocol property", ())
254254
ERROR(computed_property_missing_type,none,

lib/Parse/ParseDecl.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4158,7 +4158,7 @@ bool Parser::parseGetSetImpl(ParseDeclOptions Flags,
41584158
// Give syntax node an empty statement list.
41594159
SyntaxParsingContext StmtListContext(SyntaxContext,
41604160
SyntaxKind::CodeBlockItemList);
4161-
diagnose(Tok, diag::computed_property_no_accessors);
4161+
diagnose(Tok, diag::computed_property_no_accessors, /*subscript*/Indices != nullptr);
41624162
return true;
41634163
}
41644164

test/decl/subscript/subscripting.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ struct RetOverloadedSubscript {
172172

173173
struct MissingGetterSubscript1 {
174174
subscript (i : Int) -> Int {
175-
} // expected-error {{computed property must have accessors specified}}
175+
} // expected-error {{subscript must have accessors specified}}
176176
}
177177
struct MissingGetterSubscript2 {
178178
subscript (i : Int, j : Int) -> Int { // expected-error{{subscript declarations must have a getter}}

0 commit comments

Comments
 (0)