-
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
unification unifies different but identical types #418
Comments
@othro / @sezna: What causes this is that if two different types have the same name and the same fields then their However that unique declaration id seems like it might be the intended purpose of the enum Type {
Bool,
/* other primitive types, contracts, etc. */
Nominal(DeclId),
Unknown(UnknownTypeId),
} Where we then have a Thoughts? |
So I don't think changing the type inference algorithm is the solution here. I think just adding the full path to the declaration is good enough now, without having to worry about dependency hell yet. |
It looks to me like Since we don't even support dependency versions yet (no registry) the deps issue is an issue we can punt into the future. I think the answer here is to use a |
This is what I will be implementing. |
@emilyaherbert @canndrew was this closed by #472? Is this still an issue? |
This is still an issue,
|
With these changes `TyStructDeclaration` and `TyEnumDeclaration` now have a call path instead of a name. This is required before changing the JSON ABI to use enum and struct types with call paths instead of only names which can be duplicate. This also fixes #418 by changing `Unifier` to compare `CallPath`'s instead of `Ident`'s for enums and structs. Closes #418 --------- Co-authored-by: João Matos <joao@tritao.eu>
With these changes `TyStructDeclaration` and `TyEnumDeclaration` now have a call path instead of a name. This is required before changing the JSON ABI to use enum and struct types with call paths instead of only names which can be duplicate. This also fixes #418 by changing `Unifier` to compare `CallPath`'s instead of `Ident`'s for enums and structs. Closes #418 --------- Co-authored-by: João Matos <joao@tritao.eu>
The issue is that the module in which a struct or enum is can be imported with different callpaths. For instance we could have a struct with callpath `my_script::data_structures::SomeStruct` in a module and in another module as `my_script::eq_impls::data_structures::SomeStruct`. This makes callpaths unreliable to compare declarations. Closes #3998 Reopens #418 Disables tests multiple_enums_with_the_same_name and multiple_structs_with_the_same_name.
## Description The issue is that struct or enum can be imported with different callpaths depending the module they are imported from. For instance we could have a struct with callpath `my_script::data_structures::SomeStruct` in a module and in another module as `my_script::eq_impls::data_structures::SomeStruct`. This makes callpaths unreliable to compare declarations. Closes #3998 Reopens #418 Disables tests multiple_enums_with_the_same_name and multiple_structs_with_the_same_name because they relied in callpath comparisons to work. ## 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: Mohammad Fawaz <mohammadfawaz89@gmail.com>
#4007 reverted the fix that closed this issue, thus I am reopening it. |
Closing this issue as the tests mentioned previously are now enabled and passing. |
## Description Two disabled tests preventing #418 from being closed, are now fixed. Closes #418 ## 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.
To compile this you need to relax the rules in hll.pest to allow parsing zero-field structs. This code will then compile despite the fact that
module0::Thing
andmodule1::Thing
are two different types.The text was updated successfully, but these errors were encountered: