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

Improved trait coherence checking #6844

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

tritao
Copy link
Contributor

@tritao tritao commented Jan 20, 2025

Description

This PR implements improved trait coherence checking,

The idea of trait coherence is that, given a trait and some set of types for its type parameters, there should be exactly one impl that applies.

To check for coherence, the compiler does two separate but related checks:

  • orphan check - ensures that each impl abides by the orphan rules
  • overlap check - ensures that no two impls overlap

Right now this implements overlap checks for traits and inherent impls, without yet taking into account for trait constraints.

Checklist

  • I have linked to any relevant issues.
  • I have commented my code, particularly in hard-to-understand areas.
  • I have updated the documentation where relevant (API docs, the reference, and the Sway book).
  • I have added tests that prove my fix is effective or that my feature works.
  • I have added (or requested a maintainer to add) the necessary Breaking* or New Feature labels where relevant.
  • I have done my best to ensure that my PR adheres to the Fuel Labs Code Review Standards.
  • I have requested a review from the relevant team or maintainers.

@tritao tritao self-assigned this Jan 20, 2025
@tritao tritao added the compiler: frontend Everything to do with type checking, control flow analysis, and everything between parsing and IRgen label Jan 20, 2025
@tritao tritao force-pushed the trait-coherence branch 2 times, most recently from 3d0b994 to fd497cf Compare January 20, 2025 13:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler: frontend Everything to do with type checking, control flow analysis, and everything between parsing and IRgen
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant