Update the error message when subscripting String with Int. (#27069)

Instead of referring to a doc comment that isn't really accessible to the
developer, let's be accurate about what type they should be using here.
This commit is contained in:
Nate Cook
2019-09-10 12:23:09 -05:00
committed by GitHub
parent 4c05a35125
commit ce28cdee93
4 changed files with 17 additions and 17 deletions

View File

@@ -8,9 +8,9 @@ func test_StringSubscriptByInt(
r1: Range<Int>,
r2: ClosedRange<Int>
) {
_ = x[i] // expected-error {{'subscript(_:)' is unavailable: cannot subscript String with an Int, see the documentation comment for discussion}} {{none}}
_ = x[r1] // expected-error {{'subscript(_:)' is unavailable: cannot subscript String with an integer range, see the documentation comment for discussion}} {{none}}
_ = x[r2] // expected-error {{'subscript(_:)' is unavailable: cannot subscript String with an integer range, see the documentation comment for discussion}} {{none}}
_ = x[i] // expected-error {{'subscript(_:)' is unavailable: cannot subscript String with an Int, use a String.Index instead.}} {{none}}
_ = x[r1] // expected-error {{'subscript(_:)' is unavailable: cannot subscript String with an integer range, use a String.Index range instead.}} {{none}}
_ = x[r2] // expected-error {{'subscript(_:)' is unavailable: cannot subscript String with an integer range, use a String.Index range instead.}} {{none}}
}
func test_UTF8View(s: String.UTF8View, i: String.UTF8View.Index, d: Int) {