Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The equality comparison operator == is producing incorrect results for KeyPaths on Swift 6.0 Development Snapshots. #73554

Closed
fibrechannelscsi opened this issue May 9, 2024 · 1 comment
Labels
AnyKeyPath Area → standard library: The `AnyKeyPath` type bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. Equatable Area → standard library: The `Equatable` protocol key paths Feature: key paths (both native and Objective-C) standard library Area: Standard library umbrella swift 6.0 unexpected behavior Bug: Unexpected behavior or incorrect output

Comments

@fibrechannelscsi
Copy link
Contributor

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.

@fibrechannelscsi fibrechannelscsi added bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. triage needed This issue needs more specific labels labels May 9, 2024
@fibrechannelscsi
Copy link
Contributor Author

This appears to be fixed as of the 2024-05-14a 6.0 snapshot.
The pertinent fix is here: #73347

@AnthonyLatsis AnthonyLatsis added standard library Area: Standard library umbrella key paths Feature: key paths (both native and Objective-C) AnyKeyPath Area → standard library: The `AnyKeyPath` type unexpected behavior Bug: Unexpected behavior or incorrect output swift 6.0 Equatable Area → standard library: The `Equatable` protocol and removed triage needed This issue needs more specific labels labels May 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
AnyKeyPath Area → standard library: The `AnyKeyPath` type bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. Equatable Area → standard library: The `Equatable` protocol key paths Feature: key paths (both native and Objective-C) standard library Area: Standard library umbrella swift 6.0 unexpected behavior Bug: Unexpected behavior or incorrect output
Projects
None yet
Development

No branches or pull requests

2 participants