Skip to content

Commit 0d5bfcb

Browse files
[tests] Adding regression tests for SR-13359
1 parent d01fed2 commit 0d5bfcb

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

test/Constraints/members.swift

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -674,3 +674,18 @@ _ = [.e: 1] // expected-error {{reference to member 'e' cannot be resolved witho
674674
let _ : [Int: Any] = [1 : .e] // expected-error {{type 'Any' has no member 'e'}}
675675
let _ : (Int, Any) = (1, .e) // expected-error {{type 'Any' has no member 'e'}}
676676
_ = (1, .e) // expected-error {{cannot infer contextual base in reference to member 'e'}}
677+
678+
// SR-13359
679+
typealias Pair = (Int, Int)
680+
func testSR13359(_ pair: (Int, Int), _ alias: Pair, _ void: Void) {
681+
_ = pair[0] // expected-error {{tuple type '(Int, Int)' element cannot be accessed using subscript; did you mean to use '.' to access element?}} {{11-14=.0}}
682+
_ = pair["strting"] // expected-error {{tuple type '(Int, Int)' element cannot be accessed using subscript}} {{none}}
683+
_ = pair[-1] // expected-error {{tuple type '(Int, Int)' element cannot be accessed using subscript}} {{none}}
684+
_ = pair[1, 1] // expected-error {{tuple type '(Int, Int)' element cannot be accessed using subscript}} {{none}}
685+
_ = void[0] // expected-error {{value of type 'Void' has no subscripts}}
686+
687+
_ = alias[0] // expected-error {{tuple type 'Pair' (aka '(Int, Int)') element cannot be accessed using subscript; did you mean to use '.' to access element?}} {{12-15=.0}}
688+
_ = alias["strting"] // expected-error {{tuple type 'Pair' (aka '(Int, Int)') element cannot be accessed using subscript}} {{none}}
689+
_ = alias[-1] // expected-error {{tuple type 'Pair' (aka '(Int, Int)') element cannot be accessed using subscript}} {{none}}
690+
_ = alias[1, 1] // expected-error {{tuple type 'Pair' (aka '(Int, Int)') element cannot be accessed using subscript}} {{none}}
691+
}

0 commit comments

Comments
 (0)