You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[region-isolation] Clean up the call passes self error to be the shorter "task or actor isolated value cannot be transferred".
We do not emit these very much anymore. I am just keeping it in place a bit
longer... eventually, this should just be an unknown pattern error since if a
user sees this it won't compile and we would rather then send it to us so we can
fix it.
func testAsyncSequenceTypedPattern<Seq:AsyncSequence>(_ seq:Seq)asyncthrowswhere Seq.Element ==Int{ // expected-targeted-and-complete-note {{consider making generic parameter 'Seq' conform to the 'Sendable' protocol}} {{54-54=, Sendable}}
29
-
asyncletresult:Int= seq.reduce(0){ $0 + $1 } // expected-tns-warning {{call site passes `self` or a non-sendable argument of this function to another thread, potentially yielding a race with the caller}}
29
+
asyncletresult:Int= seq.reduce(0){ $0 + $1 } // expected-tns-warning {{task or actor isolated value cannot be transferred}}
30
30
// expected-warning @-1 {{immutable value 'result' was never used; consider replacing with '_' or removing it}}
31
31
// expected-targeted-and-complete-warning @-2 {{capture of 'seq' with non-sendable type 'Seq' in 'async let' binding}}
32
32
}
33
33
34
34
func testAsyncSequenceTypedPattern1<Seq:AsyncSequence>(_ seq:Seq)asyncthrowswhere Seq.Element ==Int{ // expected-targeted-and-complete-note {{consider making generic parameter 'Seq' conform to the 'Sendable' protocol}} {{55-55=, Sendable}}
35
-
asynclet _:Int= seq.reduce(0){ $0 + $1 } // expected-tns-warning {{call site passes `self` or a non-sendable argument of this function to another thread, potentially yielding a race with the caller}}
35
+
asynclet _:Int= seq.reduce(0){ $0 + $1 } // expected-tns-warning {{task or actor isolated value cannot be transferred}}
36
36
// expected-targeted-and-complete-warning @-1 {{capture of 'seq' with non-sendable type 'Seq' in 'async let' binding}}
37
37
}
38
38
39
39
func testAsyncSequence<Seq:AsyncSequence>(_ seq:Seq)asyncthrowswhere Seq.Element ==Int{ // expected-targeted-and-complete-note {{consider making generic parameter 'Seq' conform to the 'Sendable' protocol}} {{42-42=, Sendable}}
40
-
asyncletresult= seq.reduce(0){ $0 + $1 } // expected-tns-warning {{call site passes `self` or a non-sendable argument of this function to another thread, potentially yielding a race with the caller}}
40
+
asyncletresult= seq.reduce(0){ $0 + $1 } // // expected-tns-warning {{task or actor isolated value cannot be transferred}}
41
41
// expected-warning @-1 {{initialization of immutable value 'result' was never used; consider replacing with assignment to '_' or removing it}}
42
42
// expected-targeted-and-complete-warning @-2 {{capture of 'seq' with non-sendable type 'Seq' in 'async let' binding}}
43
43
}
44
44
45
45
func testAsyncSequence1<Seq:AsyncSequence>(_ seq:Seq)asyncthrowswhere Seq.Element ==Int{ // expected-targeted-and-complete-note {{consider making generic parameter 'Seq' conform to the 'Sendable' protocol}} {{43-43=, Sendable}}
46
-
asynclet _ = seq.reduce(0){ $0 + $1 } // expected-tns-warning {{call site passes `self` or a non-sendable argument of this function to another thread, potentially yielding a race with the caller}}
46
+
asynclet _ = seq.reduce(0){ $0 + $1 } // // expected-tns-warning {{task or actor isolated value cannot be transferred}}
47
47
// expected-targeted-and-complete-warning @-1 {{capture of 'seq' with non-sendable type 'Seq' in 'async let' binding}}
48
48
}
49
49
50
50
func testAsyncSequence3<Seq>(_ seq:Seq)asyncthrowswhere Seq:AsyncSequence, Seq.Element ==Int{ // expected-targeted-and-complete-note {{consider making generic parameter 'Seq' conform to the 'Sendable' protocol}} {{28-28=: Sendable}}
51
-
asyncletresult= seq // expected-tns-warning {{call site passes `self` or a non-sendable argument of this function to another thread, potentially yielding a race with the caller}}
51
+
asyncletresult= seq // // expected-tns-warning {{task or actor isolated value cannot be transferred}}
52
52
// expected-targeted-and-complete-warning @-1 {{capture of 'seq' with non-sendable type 'Seq' in 'async let' binding}}
53
53
//expected-warning @-2 {{initialization of immutable value 'result' was never used; consider replacing with assignment to '_' or removing it}}
54
54
}
55
55
56
56
func testAsyncSequence4<Seq>(_ seq:Seq)asyncthrowswhere Seq:AsyncSequence, Seq.Element ==Int{ // expected-targeted-and-complete-note {{consider making generic parameter 'Seq' conform to the 'Sendable' protocol}} {{28-28=: Sendable}}
57
-
asynclet _ = seq // expected-tns-warning {{call site passes `self` or a non-sendable argument of this function to another thread, potentially yielding a race with the caller}}
57
+
asynclet _ = seq // // expected-tns-warning {{task or actor isolated value cannot be transferred}}
58
58
// expected-targeted-and-complete-warning @-1 {{capture of 'seq' with non-sendable type 'Seq' in 'async let' binding}}
return x // expected-warning {{call site passes `self` or a non-sendable argument of this function to another thread, potentially yielding a race with the caller}}
113
+
return x // expected-warning {{task or actor isolated value cannot be transferred}}
114
114
}
115
115
116
116
// This is safe since we are returning the whole tuple fresh. In contrast,
0 commit comments