apple/swift-log

Swift 5.6 and 1.4.3 cause sendable errors on stringConvertible

drekka opened this issue · 8 comments

Expected behavior

Packages that depend on SwiftLog 1.4.n should compile when package resolution updates SwiftLog from 1.4.2 to 1.4.3.

The discussion in #218 indicates to me that the developers thought adding Sendable would only produce a warning. Yet over here we are seeing compilation failures and errors being issued.

Actual behavior

Packages using Logger.MetadataValue.stringConvertable(CustomStringConvertible) fail compilation if the passed CustomStringConvertible is also not Sendable.

Steps to reproduce

With an established package that uses SwiftLog 1.4.2 and something like:

logger.log(level: self.logLevel,"...",metadata: ["abc": .stringConvertible(value)])

where value has not had Sendable applied.

With 1.4.2 this would compile. With 1.4.3 it fails to compile. Placing an error on value and indicating it has to conform to Sendable.

If possible, minimal yet complete reproducer code (or URL to code)

Sorry, don't have anything I can give at this time.

SwiftLog version/commit hash

#218

342d57b

ktoso commented

This only emits a warning on 5.7, I double checked:

Screenshot 2022-08-12 at 16 10 14

swift-log: 1.4.3
Xcode: Version 14.0 beta 4 (14A5284h)

  • What is the exact error you're getting?
  • What exact versions and flags are you using?
  • Are you using -warn-concurrency which would turn warnings like these into errors?
    • If so, you're a bit jumping ahead; we don't support libraries not breaking in that (opt-in) mode. There will be many warnings what there are no workaround for in today's language, so I'd suggest not using this flag in projects unless "poking around".

Error:

Screen Shot 2022-08-12 at 5 31 27 pm

  • SwiftLog 1.4.3, Xcode 13.4.1: -
    derekclarkson@DereksDigIOMBP Edna % xcrun --find swift
    /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift
    derekclarkson@DereksDigIOMBP Edna % xcrun swift -version
    swift-driver version: 1.45.2 Apple Swift version 5.6.1 (swiftlang-5.6.0.323.66 clang-1316.0.20.12)
    
  • Brand new SPM based project so there's no project file.
  • Haven't come across -warn-concurrency and all the compiling is done through Xcode so I don't where I'd add it even if I could. Some option in the Package.swift file perhaps. Anyway, not something I've done.
ktoso commented

Oh no... this is very confusing, it seems to error on 5.6.x even though we reverted most Sendable warnings on 5.6 but it is only a warning on 5.7.

It's very true we should not be breaking 5.6 users, so we'll have to do something about that... I'll investigate our options and fix this asap.

Right now you can: pin 1.4.2 or use Swift 5.7.

FYI @DougGregor

ktoso commented

I prepared a fix for 5.6, we'll publish it shortly

Thanks @ktoso As this is a client project (who are still supporting iOS12) we are using release Xcode's so I'll pin at 1.4.2 until a patch version is released. All good here.

ktoso commented

Merged #229 and will cut a 1.4.4 with it shortly today 👍

Cool. Will try it.

ktoso commented

Released 1.4.4 to fix this - thanks for reporting!