-
Notifications
You must be signed in to change notification settings - Fork 17
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
[Graph] error encoding a component: "import name conflicts with previous name" #65
Comments
I think your assessment is probably correct, something is going wrong in the aggregation such that the transitively "used" interface of |
Which reminds me, I need to address #55 in the graph as well: |
Also, I think you're right about recursing with I think we could probably replace the |
Although, |
This commit fixes aggregation of imports that have used types. Previously, interfaces weren't being coalesced properly, resulting in duplicate imports of used interfaces that would result in an encoding validation error. The fix is to coalesce interfaces by interface identifier, merging interfaces together during the remapping process. Additionally, this fixes a bug in encoding where any implicitly imported instances were not getting their encoded indexes recorded in the encoding state properly. Also changed the map in the type aggregator to store `Type`s rather than `ItemKind`s, which makes things neater. Fixes #65.
Imagine two components targeting this world:
The following code composes these components such that the export from component 2 is supplied as the import to component 1 and then the export from component 1 is ultimately exported from the composition:
This errors with the following message:
Looking into where implicit imports are encoded in
CompositionGraphEncoder::populate_implicit_args
, it seems that the type aggregator is not dedupping interfaces as I would expect. After aggregation the aggregator'sTypes
collection has a duplicate copy of thewasi:http/[email protected]
interface.I believe the issue seems to be in
remap_interface
that the interface id associated with any used type is not in the same arena as the types inaggregated
collection. The indices seem to be the same, but when doing look ups against the aggregated collection,None
is returned.This means that we treat the used type's interface as a completely unseen interface, and we'll remap and then add it to the interfaces collection instead of seeing that it's already been aggregated. Perhaps this is ultimately correct as we can't be sure that this interface is actually equivalent to the interfaces we've seen before.
However, instead of remapping the interface and adding it to the collection of interfaces, we need to try to merge the interface with any previously seen interface with the same name. This would indicate to me that instead of doing remapping when iterating through all the used types, we need to merge the used type's interface into an existing interface with the same name.
I believe this is what the
aggregate
method essentially does, so perhaps the right answer is to callaggregate
instead ofremap_interface
. This would require threading thecache
down intoremap_interface
and makingremap_interface
fallible as the merging could potentially fail. This would also require making a version ofaggregate
that does not consumeself
.Am I thinking about this correctly or am I totally off base?
The text was updated successfully, but these errors were encountered: