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 find_method_for_type bail out with 1st match #6606

Merged
merged 8 commits into from
Oct 30, 2024
Merged

Conversation

esdrubal
Copy link
Contributor

@esdrubal esdrubal commented Oct 4, 2024

Description

When find_method_for_type could not match the parameters and return type with the available methods it would return the first match by name.

This was not a deterministic and secure behavior so now we strictly match the parameter and return types.

Fixes #5086

find_method_for_type now if we have: impl FromBytes for T
and: impl FromBytes for DataPoint, we pick the second implementation.

Fixes #6572

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 compiler: frontend Everything to do with type checking, control flow analysis, and everything between parsing and IRgen labels Oct 4, 2024
@esdrubal esdrubal self-assigned this Oct 4, 2024
Copy link

codspeed-hq bot commented Oct 4, 2024

CodSpeed Performance Report

Merging #6606 will degrade performances by 35.42%

Comparing esdrubal/5086 (b5e6e4e) with master (0555973)

Summary

❌ 1 regressions
✅ 21 untouched benchmarks

⚠️ Please fix the performance issues or acknowledge them on CodSpeed.

Benchmarks breakdown

Benchmark master esdrubal/5086 Change
prepare_rename 1.6 ms 2.5 ms -35.42%

When find_method_for_type could not match the parameters and return type
with the available methods it would return the first match by name.

This was not a deterministic and secure behavior so now we strictly
match the parameter types and return type.

Fixes #5086
find_method_for_type now if we have: impl<T> FromBytes for T
and: impl FromBytes for DataPoint, we pick the second implementation.

Fixes #6572
@esdrubal esdrubal marked this pull request as ready for review October 29, 2024 11:30
@esdrubal esdrubal requested a review from a team as a code owner October 29, 2024 11:30
@IGI-111 IGI-111 requested a review from a team October 29, 2024 12:49
Copy link
Contributor

@jjcnn jjcnn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One minor comment, but otherwise it looks good.

Some of the methods in type_check_context.rs are getting a bit long - I wonder if we should put some time into refactoring them?

@esdrubal esdrubal merged commit 139b5b6 into master Oct 30, 2024
40 checks passed
@esdrubal esdrubal deleted the esdrubal/5086 branch October 30, 2024 10:44
sdankel pushed a commit that referenced this pull request Oct 30, 2024
## Description

When find_method_for_type could not match the parameters and return type
with the available methods it would return the first match by name.

This was not a deterministic and secure behavior so now we strictly
match the parameter and return types.

Fixes #5086

find_method_for_type now if we have: impl<T> FromBytes for T
and: impl FromBytes for DataPoint, we pick the second implementation.

Fixes #6572

## Checklist

- [x] I have linked to any relevant issues.
- [x] 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).
- [ ] If my change requires substantial documentation changes, I have
[requested support from the DevRel
team](https://github.com/FuelLabs/devrel-requests/issues/new/choose)
- [x] I have added tests that prove my fix is effective or that my
feature works.
- [x] I have added (or requested a maintainer to add) the necessary
`Breaking*` or `New Feature` labels where relevant.
- [x] I have done my best to ensure that my PR adheres to [the Fuel Labs
Code Review
Standards](https://github.com/FuelLabs/rfcs/blob/master/text/code-standards/external-contributors.md).
- [x] I have requested a review from the relevant team or maintainers.

---------

Co-authored-by: IGI-111 <[email protected]>
Co-authored-by: Joshua Batty <[email protected]>
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
Projects
None yet
4 participants