Skip to content

Prefer casting rhs to lhs when unifying equality operators #12190

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

Open
wants to merge 1 commit into
base: development
Choose a base branch
from

Conversation

Simn
Copy link
Member

@Simn Simn commented Apr 19, 2025

It was found that when doing lhs == rhs, the compiler first tries to assign lhs to rhs and thus also prefers implicit casts in that direction, which seems unintuitive. This change flips the order and so the algorithm is this:

  1. try casting rhs to lhs
  2. if that fails, try casting lhs to rhs
  3. if that fails too, report the error from the first attempt

I think that's more natural. This is a pretty central change though because it has probably been like that since the original introduction of abstracts. Our unit tests seem fine but there's a failure in the tink tests:

Refs: [./tests/Refs.hx:6]
  testImplicit: [./tests/Refs.hx:7] 
    - [FAIL] [./tests/Refs.hx:9] r == 5 (@[5] == @[5])

cc @back2dos

@skial skial mentioned this pull request Apr 24, 2025
1 task
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant