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] Make sure to look through begin_access and don't treat it like an assignment.
If we treat a begin_access as an assignment then in cases like below we assume
that a value was used before we reassign.
```
func testVarReassignStopActorDerived() async {
var closure = {}
await transferToMain(closure)
// This re-assignment shouldn't error.
closure = {} // (1)
}
```
rdar://117437299
Copy file name to clipboardExpand all lines: test/Concurrency/sendnonsendable_basic.swift
+15-3Lines changed: 15 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -174,8 +174,20 @@ extension Actor {
174
174
letclosure:()->()={
175
175
print(self.klass)
176
176
}
177
-
letx=(closure,1)
177
+
letx=(1, closure)
178
178
awaittransferToMain(x) // expected-sns-warning {{call site passes `self` or a non-sendable argument of this function to another thread, potentially yielding a race with the caller}}
179
+
// expected-complete-warning @-1 {{passing argument of non-sendable type '(Int, () -> ())' into main actor-isolated context may introduce data races}}
180
+
// expected-complete-note @-2 {{a function type must be marked '@Sendable' to conform to 'Sendable'}}
// NOTE: We do not error on this today since we assign into 1 and that makes
188
+
// x assign fresh. It will be fixed in a forthcoming commit.
189
+
letx=(closure,1)
190
+
awaittransferToMain(x)
179
191
// expected-complete-warning @-1 {{passing argument of non-sendable type '(() -> (), Int)' into main actor-isolated context may introduce data races}}
180
192
// expected-complete-note @-2 {{a function type must be marked '@Sendable' to conform to 'Sendable'}}
181
193
}
@@ -451,11 +463,11 @@ extension Actor {
451
463
452
464
// This re-assignment shouldn't error.
453
465
closure ={}
454
-
awaittransferToMain(closure)
466
+
awaittransferToMain(closure) // expected-sns-warning {{passing argument of non-sendable type '() -> ()' from actor-isolated context to main actor-isolated context at this call site could yield a race with accesses later in this function}}
455
467
// expected-complete-warning @-1 {{passing argument of non-sendable type '() -> ()' into main actor-isolated context may introduce data races}}
456
468
// expected-complete-note @-2 {{a function type must be marked '@Sendable' to conform to 'Sendable'}}
457
469
458
470
// But this will error since we race.
459
-
closure()
471
+
closure() // expected-sns-note {{access here could race}}
0 commit comments