Skip to content

Commit 5bca066

Browse files
committed
Adding top-level sync call with inout global actor state
Adding a call at the top-level that takes global actor state via an inout outside of the global actor context. This is not legal.
1 parent f3da35a commit 5bca066

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

test/Concurrency/global_actor_from_ordinary_context.swift

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,4 +128,11 @@ func fromAsync() async {
128128

129129
_ = a[1] // expected-error{{subscript 'subscript(_:)' isolated to global actor 'SomeGlobalActor' can not be referenced from this context}}
130130
a[0] = 1 // expected-error{{subscript 'subscript(_:)' isolated to global actor 'SomeGlobalActor' can not be referenced from this context}}
131-
}
131+
}
132+
133+
// expected-note@+1{{mutable state is only available within the actor instance}}
134+
@SomeGlobalActor var value: Int = 42
135+
136+
func topLevelSyncFunction(_ number: inout Int) { }
137+
// expected-error@+1{{var 'value' isolated to global actor 'SomeGlobalActor' can not be referenced from this context}}
138+
topLevelSyncFunction(&value)

0 commit comments

Comments
 (0)