Use of `static var` constants instead of `static let`
mansbernhardt opened this issue · comments
When building code using -warn-concurrency, the compiler will return warnings when using "constants" from Euclid, as they are declared static var
instead of static let
such as e.g.:
public extension Color {
static var clear = Color(0, 0)
static var black = Color(0)
static var white = Color(1)
static let gray = Color(0.5)
returns this warning when accessing white:
Reference to static property 'white' is not concurrency-safe because it involves shared mutable state
I suggest updating all constants to use let instead of var.
Related to this, are there any plans to upgrade Euclid for concurrency such as adding Sendable
conformances?
@mansbernhardt thanks for reporting this. I've fixed that and also added Sendable conformances on the develop branch. I had to add unchecked conformance for the Material handling (which isn't truly thread safe), but I'll consider how that might be improved in future.
Thanks @nicklockwood!