-
Notifications
You must be signed in to change notification settings - Fork 5.4k
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
Adds Hash trait and Hasher struct to std lib. #4701
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 tasks
IGI-111
pushed a commit
that referenced
this pull request
Jul 10, 2023
## Description We were not calling replace_decl for variable declarations. This was making some trait method calls to not be replaced. Unblocks #4701 Fixes #4773 ## 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). - [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.
esdrubal
force-pushed
the
esdrubal/hash
branch
3 times, most recently
from
July 10, 2023 14:22
b5eb0b6
to
542c84a
Compare
esdrubal
added
the
breaking
May cause existing user code to break. Requires a minor or major release.
label
Jul 10, 2023
tritao
reviewed
Jul 10, 2023
tritao
reviewed
Jul 10, 2023
tritao
reviewed
Jul 10, 2023
tritao
reviewed
Jul 10, 2023
tritao
reviewed
Jul 10, 2023
test/src/e2e_vm_tests/test_programs/should_pass/stdlib/option/src/data_structures.sw
Outdated
Show resolved
Hide resolved
test/src/e2e_vm_tests/test_programs/should_pass/stdlib/option/src/data_structures.sw
Outdated
Show resolved
Hide resolved
test/src/e2e_vm_tests/test_programs/should_pass/stdlib/option/src/tests.sw
Outdated
Show resolved
Hide resolved
xunilrj
reviewed
Jul 13, 2023
esdrubal
added a commit
that referenced
this pull request
Jul 17, 2023
The issue this commit solves is the method not found error thrown when when we try to use generic traits. This issue was fixed by adding support to the `unify_check` so left types can match right types `UnknownGeneric`. We also check that the left type implemnts the trait constraints of the `UnknownGeneric` before return true. Fixes #4806 Unblocks #4701
7 tasks
esdrubal
added a commit
that referenced
this pull request
Jul 17, 2023
The issue this commit solves is the method not found error thrown when when we try to use generic traits. This issue was fixed by adding support to the `unify_check` so left types can match right types `UnknownGeneric`. We also check that the left type implemnts the trait constraints of the `UnknownGeneric` before return true. Fixes #4806 Unblocks #4701
esdrubal
added a commit
that referenced
this pull request
Jul 19, 2023
The issue this commit solves is the method not found error thrown when we try to use generic traits. This issue was fixed by calling `insert_trait_implementation_for_type` while resolving tuples and arrays, we also call `insert_trait_implementation_for_type` as a fail safe when a method is not found. Fixes #4806 Unblocks #4701
esdrubal
added a commit
that referenced
this pull request
Jul 19, 2023
The issue this commit solves is the method not found error thrown when we try to use generic traits. This issue was fixed by calling `insert_trait_implementation_for_type` while resolving tuples and arrays, we also call `insert_trait_implementation_for_type` as a fail safe when a method is not found. Fixes #4806 Unblocks #4701
esdrubal
added a commit
that referenced
this pull request
Jul 20, 2023
## Description The issue this commit solves is the method not found error thrown when we try to use generic traits. This issue was fixed by calling `insert_trait_implementation_for_type` while resolving tuples and arrays, we also call `insert_trait_implementation_for_type` as a fail-safe when a method is not found. Fixes #4806 Unblocks #4701 ## 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). - [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: Anton Trunov <anton.a.trunov@gmail.com>
I'm wondering if this issue #3835 is related. Should it be closed after this PR is merged? |
It should, yeah. |
esdrubal
force-pushed
the
esdrubal/hash
branch
3 times, most recently
from
August 4, 2023 10:12
75f5566
to
1bd50e1
Compare
Implements Hash trait for builtin types and for some std lib types. This is required to have a proper hashing that does not change in case the internal memory representation of type changes. Current hashing functions are hashing the types in memory directly, as this representation might change in future versions of the VM and compiler we want to have a more reliable way of getting hashes that won't change in future versions of the compiler and std lib. Replaces use of sha256 function with Hasher in storage_map and storage_vec. Adds intrinsic __check_str_type. __check_str_type returns an error at compile time in case the provided generic type is not a str. This is used to guarantee that `Hasher` `write_str` is not called with non str types.
esdrubal
force-pushed
the
esdrubal/hash
branch
from
August 15, 2023 11:45
1bd50e1
to
518c0cc
Compare
The PR is finally green, all review requests were addressed. Ready for review again. |
IGI-111
reviewed
Aug 17, 2023
Small nit but LGTM |
tritao
approved these changes
Aug 18, 2023
IGI-111
approved these changes
Aug 18, 2023
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Implements Hash trait for builtin types and for some std lib types.
This is required to have a proper hashing that does not change in case the internal memory representation of type changes.
Current hashing functions are hashing the types in memory directly, as this representation might change in future versions of the VM and compiler we want to have a more reliable way of getting hashes that won't change in future versions of the compiler and std lib.
Replaces use of sha256 function with Hasher in storage_map and storage_vec.
Adds intrinsic __check_str_type.
__check_str_type returns an error at compile time in case the provided generic type is not a str.
This is used to guarantee that
Hasher
write_str
is not called with non str types.Closes #3835.
Checklist
Breaking*
orNew Feature
labels where relevant.