Skip to content

Commit a18dc11

Browse files
authored
Merge pull request #17176 from mdiep/no-subscript-members-error
2 parents cb3d6e2 + 863d7d3 commit a18dc11

File tree

6 files changed

+8
-8
lines changed

6 files changed

+8
-8
lines changed

include/swift/AST/DiagnosticsSema.def

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,8 @@ ERROR(ambiguous_member_overload_set,none,
6262
ERROR(ambiguous_subscript,none,
6363
"ambiguous subscript with base type %0 and index type %1",
6464
(Type, Type))
65-
ERROR(type_not_subscriptable,none,
66-
"type %0 has no subscript members",
65+
ERROR(could_not_find_value_subscript,none,
66+
"value of type %0 has no subscripts",
6767
(Type))
6868

6969
ERROR(could_not_find_tuple_member,none,

lib/Sema/CSDiag.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1382,7 +1382,7 @@ diagnoseUnviableLookupResults(MemberLookupResult &result, Type baseObjTy,
13821382

13831383
// TODO: This should handle tuple member lookups, like x.1231 as well.
13841384
if (memberName.getBaseName().getKind() == DeclBaseName::Kind::Subscript) {
1385-
diagnose(loc, diag::type_not_subscriptable, baseObjTy)
1385+
diagnose(loc, diag::could_not_find_value_subscript, baseObjTy)
13861386
.highlight(baseRange);
13871387
} else if (memberName.getBaseName() == "deinit") {
13881388
// Specialised diagnostic if trying to access deinitialisers

test/ClangImporter/attr-swift_private.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,8 @@ public func testFactoryMethods() {
6565

6666
#if !IRGEN
6767
public func testSubscript(_ foo: Foo) {
68-
_ = foo[foo] // expected-error {{type 'Foo' has no subscript members}}
69-
_ = foo[1] // expected-error {{type 'Foo' has no subscript members}}
68+
_ = foo[foo] // expected-error {{value of type 'Foo' has no subscripts}}
69+
_ = foo[1] // expected-error {{value of type 'Foo' has no subscripts}}
7070
}
7171
#endif
7272

test/ClangImporter/objc_parse.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ func overridingTest(_ srs: SuperRefsSub) {
241241
}
242242

243243
func almostSubscriptableValueMismatch(_ as1: AlmostSubscriptable, a: A) {
244-
as1[a] // expected-error{{type 'AlmostSubscriptable' has no subscript members}}
244+
as1[a] // expected-error{{value of type 'AlmostSubscriptable' has no subscripts}}
245245
}
246246

247247
func almostSubscriptableKeyMismatch(_ bc: BadCollection, key: NSString) {

test/Constraints/diagnostics.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -651,7 +651,7 @@ _ = -UnaryOp() // expected-error {{unary operator '-' cannot be applied to an op
651651
// <rdar://problem/23433271> Swift compiler segfault in failure diagnosis
652652
func f23433271(_ x : UnsafePointer<Int>) {}
653653
func segfault23433271(_ a : UnsafeMutableRawPointer) {
654-
f23433271(a[0]) // expected-error {{type 'UnsafeMutableRawPointer' has no subscript members}}
654+
f23433271(a[0]) // expected-error {{value of type 'UnsafeMutableRawPointer' has no subscripts}}
655655
}
656656

657657

test/decl/subscript/subscripting.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ struct MissingGetterSubscript2 {
182182

183183
func test_subscript(_ x2: inout X2, i: Int, j: Int, value: inout Int, no: NoSubscript,
184184
ovl: inout OverloadedSubscript, ret: inout RetOverloadedSubscript) {
185-
no[i] = value // expected-error{{type 'NoSubscript' has no subscript members}}
185+
no[i] = value // expected-error{{value of type 'NoSubscript' has no subscripts}}
186186

187187
value = x2[i]
188188
x2[i] = value

0 commit comments

Comments
 (0)