From 1e11704a7a850c4cd7a340888a1237b2442bf59b Mon Sep 17 00:00:00 2001 From: Arnaud Wurmel Date: Fri, 23 Apr 2021 14:41:25 +0200 Subject: [PATCH] Fix crash with atomic values --- Sources/Atomic.swift | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Sources/Atomic.swift b/Sources/Atomic.swift index e5db19d..d7453c1 100644 --- a/Sources/Atomic.swift +++ b/Sources/Atomic.swift @@ -69,8 +69,9 @@ final class Atomic { @discardableResult func modify(action: (Value) throws -> Value) rethrows -> Value { return try withValue { value in + let oldValue = value _value = try action(value) - return value + return oldValue } }