Giter Site home page Giter Site logo

Comments (13)

gongzhang avatar gongzhang commented on May 25, 2024 2

image

Swift 5.7 does allow Any value to store a wildcard nil. Therefore the case nil is already useless in Swift 5.7. I think wrap the case in #if swift(<5.7) is a solution.

from swiftyjson.

HangyuYe avatar HangyuYe commented on May 25, 2024

With same warning

from swiftyjson.

smixik avatar smixik commented on May 25, 2024

Same here

from swiftyjson.

gongzhang avatar gongzhang commented on May 25, 2024

Same here. I think we can just delete this case, right?

from swiftyjson.

santirodriguezaffonso avatar santirodriguezaffonso commented on May 25, 2024

"Swift 6" on warning? The latest version is 5.7 πŸ€₯
https://www.swift.org/download/

Currently I'm using Xcode 14, pod --version (1.11.3) & SwiftyJSON (5.0.0) and it works fine.

from swiftyjson.

owenDecorus avatar owenDecorus commented on May 25, 2024

"Swift 6" on warning? The latest version is 5.7 πŸ€₯ https://www.swift.org/download/

No lying going on here. What this error means is that the issue will become a build error, and not just a warning, when we inevitably get Swift 6.

To add to the issue, I am seeing this as well. It's not really an issue right now obviously as everything is still working fine but, for whatever reason, we won't be able to build in Swift 6 because of this.

from swiftyjson.

luoxiu avatar luoxiu commented on May 25, 2024

Actually, it allows:

let n: Int? = nil
let x: Any = n as Any
image

Swift 5.7 does allow Any value to store a wildcard nil. Therefore the case nil is already useless in Swift 5.7. I think wrap the case in #if swift(<5.7) is a solution.

from swiftyjson.

gongzhang avatar gongzhang commented on May 25, 2024

Indeed you can assign nil to Any, sorry I was wrong.

πŸ‘ After further research, even if nil is assigned explicitly, it is not equal to a naked nil. (Because the value is Optional<Int>.none)

let a: Int? = nil
let b: Any = a as Any

print(b) // nil
print(type(of: b)) // Optional<Int>

if case nil = b { // false
    // ❌ never
}

if case Optional<Int>.none = b { // true
    // βœ… matched
}

Actually, it allows:

let n: Int? = nil
let x: Any = n as Any
image Swift 5.7 does allow `Any` value to store a wildcard `nil`. Therefore the `case nil` is already useless in Swift 5.7. I think wrap the case in `#if swift(<5.7)` is a solution.

from swiftyjson.

luoxiu avatar luoxiu commented on May 25, 2024

Changing case nil: to case Optional<Any>.none: will fix this issue, already raised a pr here: #1124.

from swiftyjson.

gongzhang avatar gongzhang commented on May 25, 2024

@luoxiu πŸ€” Is it really possible to get into the branch of Optional<Any>.none? I still feel that case nil should be removed directly.

from swiftyjson.

luoxiu avatar luoxiu commented on May 25, 2024

@luoxiu πŸ€” Is it really possible to get into the branch of Optional<Any>.none? I still feel that case nil should be removed directly.

Yes, take a look at the test I added to pr.

from swiftyjson.

gongzhang avatar gongzhang commented on May 25, 2024

@luoxiu hmmm... looks good to me

from swiftyjson.

HangyuYe avatar HangyuYe commented on May 25, 2024

We need to wait for a new swift package to fix the issue, or is there some workaround to skip this warning on the current swift pak.

from swiftyjson.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.