Comments (13)
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.
With same warning
from swiftyjson.
Same here
from swiftyjson.
Same here. I think we can just delete this case, right?
from swiftyjson.
"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.
"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.
Actually, it allows:
let n: Int? = nil
let x: Any = n as Any
Swift 5.7 does allow
Any
value to store a wildcardnil
. Therefore thecase nil
is already useless in Swift 5.7. I think wrap the case in#if swift(<5.7)
is a solution.
from swiftyjson.
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 AnySwift 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.
Changing case nil:
to case Optional<Any>.none:
will fix this issue, already raised a pr here: #1124.
from swiftyjson.
@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 π€ Is it really possible to get into the branch of
Optional<Any>.none
? I still feel thatcase nil
should be removed directly.
Yes, take a look at the test I added to pr.
from swiftyjson.
@luoxiu hmmm... looks good to me
from swiftyjson.
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)
- Crash on iOS 15 HOT 5
- Please assist urgent HOT 1
- Data parsing get is null
- Jcharlyπ€
- What is SwiftJSON latest version as per current date(20/06/022 stable version only) which supports iOS 15+ AND what is Alamofire version which supports iOS 15+, both should supports iOS 15 and it's Above version.
- How to test if a property exists on a JSON object? HOT 1
- How to read emojis in JSON
- Type 'Any' is not optional, value can never be nil; this is an error in Swift 6 HOT 2
- How to update a field of a SwiftyJSON object
- New version release - When? HOT 11
- Json cert
- Recommended way to conform `JSON` to `Hashable` HOT 4
- Empty dictionary object cannot insert data HOT 2
- unwrap crash HOT 1
- Privacy manifest required by Apple HOT 9
- Errors in readme HOT 1
- Privacy Manifest HOT 5
- Is this repository no longer maintained? whyοΌ HOT 4
- STACK CANARY problem
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from swiftyjson.