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

Fixes missing error on type unification. #5230

Merged
merged 5 commits into from
Nov 3, 2023

Conversation

esdrubal
Copy link
Contributor

@esdrubal esdrubal commented Oct 26, 2023

Description

While using generic blanket implementation no error was thrown when another type other than the generic blanket expected type was used.

This was caused by the typechecker being too permissive in UnknownGeneric unification. The fix changes the unifier to handle unification with the expected self and generics as special cases.

Closes #5212
Closes #5162

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.

@esdrubal esdrubal added bug Something isn't working P: high Should be looked at if there are no critical issues left compiler: frontend Everything to do with type checking, control flow analysis, and everything between parsing and IRgen labels Oct 26, 2023
@esdrubal esdrubal self-assigned this Oct 26, 2023
@esdrubal esdrubal force-pushed the esdrubal/fix_generic_impl_trait_missing_error branch 3 times, most recently from 7d9ce80 to 77dd59c Compare October 27, 2023 13:09
@esdrubal esdrubal requested a review from a team October 27, 2023 14:22
@esdrubal esdrubal marked this pull request as ready for review October 27, 2023 14:22
@IGI-111 IGI-111 requested a review from a team October 30, 2023 13:30
@IGI-111
Copy link
Contributor

IGI-111 commented Oct 30, 2023

If we're going to have multiple modes like this, it might be a good idea to refactor the unifier to work like UnifyCheck.

@IGI-111 IGI-111 requested a review from a team October 30, 2023 13:36
@esdrubal
Copy link
Contributor Author

esdrubal commented Nov 1, 2023

If we're going to have multiple modes like this, it might be a good idea to refactor the unifier to work like UnifyCheck.

The Unifier so far only has to handle the self and generic special cases which can be contained in the same match expression with a simple conditional check in the respective match arm.

@esdrubal
Copy link
Contributor Author

esdrubal commented Nov 2, 2023

Added test showing that #5162 is resolved with the changes proposed in this PR.

@esdrubal esdrubal force-pushed the esdrubal/fix_generic_impl_trait_missing_error branch from 181acad to cdfeefd Compare November 2, 2023 14:45
While using generic blanket implementation no error was thrown when another
type other than the generic blanket expected type was used.

This was caused by the typechecker being too permissive in UnknownGeneric
unification. The fix changes the unifier to handle unification with the expected
self and generics as special cases.

Closes #5212
@IGI-111 IGI-111 requested review from tritao and a team November 2, 2023 23:21
@IGI-111 IGI-111 enabled auto-merge (squash) November 3, 2023 00:21
@IGI-111 IGI-111 merged commit 74b802c into master Nov 3, 2023
28 checks passed
@IGI-111 IGI-111 deleted the esdrubal/fix_generic_impl_trait_missing_error branch November 3, 2023 00:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working compiler: frontend Everything to do with type checking, control flow analysis, and everything between parsing and IRgen P: high Should be looked at if there are no critical issues left
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Generic impl trait compiling when it shouldn't. Generics and associated types clash
4 participants