Given this
// uniqueId.swift
private var v: Int = 0
@MainActor
func uniqueId () -> Int {
defer {v += 1}
return v
}
Why the error?
var 'v' is not concurrency-safe because it is nonisolated global shared mutable state
var v
is private, it is used only inside the main-actor isolated func uniqueId
, and therefore it is inherently concurrency-safe. no?