[Bugfix] Invalid generation of types with >1 generic parameters#1023
Merged
tadeohepperle merged 3 commits intoJun 23, 2023
Merged
Conversation
…ltiple-generic-parameters
jsdw
approved these changes
Jun 21, 2023
jsdw
left a comment
Contributor
There was a problem hiding this comment.
Nice job! Also love the test :)
lexnv
reviewed
Jun 23, 2023
| } | ||
|
|
||
| #[test] | ||
| fn more_than_1_generic_parameters_work() { |
niklasad1
reviewed
Jun 23, 2023
| use scale_info::{meta_type, IntoPortable, TypeInfo}; | ||
| use scale_info::{meta_type, IntoPortable, PortableRegistry, Registry, TypeInfo}; | ||
| use subxt_codegen::{CratePath, DerivesRegistry, RuntimeGenerator, TypeSubstitutes}; | ||
| use syn::__private::quote; |
Contributor
There was a problem hiding this comment.
hrm, does that compile? :)
It would be better to bring in quote in dependency tree as this might break between releases...
Contributor
Author
There was a problem hiding this comment.
I could do that, good idea.
tadeohepperle
added a commit
that referenced
this pull request
Jul 4, 2023
* add original name match * add unit test for generic params
Merged
This file contains hidden or 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
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.
fixes #550
Investigated reason for the bug: In subxt, when calling
resolve_field_type_path()to get the type of a generic, we were not taking into account multiple generics with different names (originial_namee.g.T,U,V, ...). The function just looked for the first type where the type (e.g.u8) matches (see:parent_type_params.iter().find(...)).Fix: add an optional parameter
original_name: Option<&str>to the type resolving function to also check the name of the generic argument.Added a test to confirm the behavior is now as desired. The test matches the problem statement in #550.