Skip to content

Commit

Permalink
fix: ensure composite inners are resolved to known types
Browse files Browse the repository at this point in the history
  • Loading branch information
glihm committed Jul 23, 2024
1 parent 5cb2490 commit 338e30b
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions crates/parser/src/abi/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,32 @@ impl AbiParser {
}
}

// Can be a very huge copy here. Need an other way to do that in the loop
// above here.
let filtered = tokens_filtered.clone();

// So now once it's filtered, we may actually iterate again on the tokens
// to resolve all structs/enums inners that may reference existing types.
for (name, tokens) in tokens_filtered.iter_mut() {
if let Token::Composite(ref mut composite) = tokens {
for inner in &mut composite.inners {
if let Token::Composite(ref mut inner_composite) = inner.token {
if inner_composite.r#type == CompositeType::Unknown {
inner.token = filtered
.get(&inner.token.type_path())
.expect(&format!(
"In composite {} the inner token type for {} is expected to exist: {}",
name,
inner.name,
inner.token.type_path()
))
.clone();
}
}
}
}
}

tokens_filtered
}
}

0 comments on commit 338e30b

Please sign in to comment.