sindresorhus / Defaults

💾 Swifty and modern UserDefaults
https://swiftpackageindex.com/sindresorhus/Defaults/documentation/defaults
MIT License
1.93k stars 115 forks source link

Optional Keys crash Xcode 16 #177

Closed ConfusedVorlon closed 2 weeks ago

ConfusedVorlon commented 1 month ago

It seems that optional keys are not caught by

        if (defaultValue as? _DefaultsOptionalProtocol)?._defaults_isNil == true {
            return
        }

The good news is that this is caught in the tests...

ConfusedVorlon commented 1 month ago

XCode 15.4 defines ExpressibleByNilLiteral

Conforming Types [Optional]

XCode 16 states:

[Optional] Conforms when Wrapped conforms to Escapable.

meanwhile, Escapable seems to have no requirements, but not to be available without

-enable-experimental-feature NonescapableTypes

If I do enable that feature, then compilation fails with a circular reference as soon as I include a key

sindresorhus commented 1 month ago

I recommend reporting this to Apple. It looks like a Swift bug.

hank121314 commented 1 month ago

It seems to be the same as this issue: https://github.com/apple/swift/issues/74282

sindresorhus commented 1 month ago

You could use this workaround for now: https://github.com/sindresorhus/Defaults/commit/5434b04cb418a6975b5d149edb9ae1da4eb0d9a9

It works as long as you don't use AnySerializable.

ConfusedVorlon commented 1 month ago

Brilliant - thank you.

ConfusedVorlon commented 3 weeks ago

fyi - not fixed on beta 2

ConfusedVorlon commented 2 weeks ago

Fixed in Beta 3 :)