mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Most tests were using %swift or similar substitutions, which did not include the target triple and SDK. The driver was defaulting to the host OS. Thus, we could not run the tests when the standard library was not built for OS X. Swift SVN r24504
52 lines
1.0 KiB
Swift
52 lines
1.0 KiB
Swift
// RUN: %target-parse-verify-swift
|
|
|
|
struct X { }
|
|
struct Y { }
|
|
|
|
struct WithOverloadedSubscript {
|
|
subscript(i: Int) -> X {
|
|
get {}
|
|
set {}
|
|
}
|
|
subscript(i: Int) -> Y {
|
|
get {}
|
|
set {}
|
|
}
|
|
}
|
|
|
|
func test_assign() {
|
|
var a = WithOverloadedSubscript()
|
|
a[0] = X()
|
|
a[0] = Y()
|
|
}
|
|
|
|
var i: X
|
|
var j: X
|
|
var f: Y
|
|
func getXY() -> (X, Y) {}
|
|
var ift : (X, Y)
|
|
var ovl = WithOverloadedSubscript()
|
|
|
|
var slice: [X]
|
|
|
|
i = j
|
|
(i, f) = getXY()
|
|
(i, f) = ift
|
|
(i, f) = (i, f)
|
|
(ovl[0], ovl[0]) = ift
|
|
(ovl[0], ovl[0]) = (i, f)
|
|
(_, ovl[0]) = (i, f)
|
|
(ovl[0], _) = (i, f)
|
|
_ = (i, f)
|
|
slice[7] = i
|
|
|
|
slice[7] = f // expected-error{{cannot assign a value of type 'Y' to a value of type 'X'}}
|
|
|
|
slice[7] = _ // expected-error{{'_' can only appear in a pattern or on the left side of an assignment}}
|
|
|
|
func value(x: Int) {}
|
|
func value2(inout x: Int) {}
|
|
value2(&_) // expected-error{{'_' can only appear in a pattern or on the left side of an assignment}}
|
|
value(_) // expected-error{{'_' can only appear in a pattern or on the left side of an assignment}}
|
|
|