-
Notifications
You must be signed in to change notification settings - Fork 10.6k
Description
Description
There are cases when the equality comparison operator == is returning true when it ought to return false. Here, both sides involve KeyPaths, but the KeyPaths themselves are different.
Reproduction
Run the below code (built either in Debug or Release mode) with a recent Swift 6.0 Development Snapshot (2024-04-30 tested).
struct O {var a: Int}
struct I {var b: Int}
print(\I.b == \O.a)Expected behavior
The above code should print false.
Environment
Swift Development Snapshot 6.0 (2024-04-29a and 2024-04-30a) are affected.
If using Xcode, one can create a new xcodeproj, paste in the above code, switch to a 6.0-branch toolchain, and run.
This problem also occurs in Ubuntu 20 with an x86 machine.
Note that when running the executable on a MacOS terminal window, the executable itself ought to be using the libswiftCore.dylib corresponding to a 6.0-based toolchain, rather than the default system one.
Additional information
None of the nightly toolchains (i.e, 2024-05-01a) nor anything on the 5.10 branch appears to be affected.