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 error while using generic From and Into traits. #5218

Merged
merged 2 commits into from
Oct 25, 2023

Conversation

esdrubal
Copy link
Contributor

@esdrubal esdrubal commented Oct 23, 2023

Description

This commit fixes 2 errors:
First error:

60 |     let _i: Struct3 = 1_u64.into();
   |                             ^^^^ Trait "MyFrom" is not implemented for type "U".

Second error:

60 |     let _i: Struct3 = 1_u64.into();
   |                             ^^^^ Trait "MyFrom" is not implemented for type "Struct3".

The first fix is to unify the method return type with the current ctx.type_annotation().
The second fix is to substitute the generic blanket type with call_path_typeid.

Closes #5208

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 23, 2023
@esdrubal esdrubal self-assigned this Oct 23, 2023
@esdrubal esdrubal requested a review from a team October 23, 2023 13:56
@esdrubal esdrubal marked this pull request as ready for review October 23, 2023 13:56
@IGI-111 IGI-111 requested a review from a team October 24, 2023 10:27
@esdrubal esdrubal force-pushed the esdrubal/fix_into_trait_error2 branch from 33735e3 to 49c47f1 Compare October 24, 2023 15:11
This commit fixes 2 errors:
First error:
```
60 |     let _i: Struct3 = 1_u64.into();
   |                             ^^^^ Trait "MyFrom" is not implemented for type "U".
```
Second error:
```
60 |     let _i: Struct3 = 1_u64.into();
   |                             ^^^^ Trait "MyFrom" is not implemented for type "Struct3".
```

First fix is to unify method return type with current ctx.type_annotation().
Second fix is to substituting the generic blanket type by call_path_typeid.

Closes #5208
@IGI-111 IGI-111 enabled auto-merge (squash) October 25, 2023 10:30
@IGI-111 IGI-111 merged commit d5b0c06 into master Oct 25, 2023
28 checks passed
@IGI-111 IGI-111 deleted the esdrubal/fix_into_trait_error2 branch October 25, 2023 11:19
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.

Unexpected error while using generic From and Into traits.
3 participants