Currently type resolution does not handle namespaces correctly, causing such example to fail:
alloy_sol_types::sol! {
library LibA {
struct B {
uint256 val;
}
struct A {
B val;
}
}
library LibB {
struct Nested {
uint256 val1;
LibA.A val2;
}
}
contract A {
function get_val(LibB.Nested memory user) external;
}
}
When resolving LibB.Nested we'll enter LibA.A type which contains B struct. However, we don't set namespace to LibA, and will instead try to resolve B as item of LibB, which would fail.
Solution
I've updated resolve_custom_types fn to use custom Resolver visitor which keeps track of namespace, updates it before entering a type from another namespace and resets it to previous value after type is processed.
Motivation
Currently type resolution does not handle namespaces correctly, causing such example to fail:
When resolving
LibB.Nested
we'll enterLibA.A
type which containsB
struct. However, we don't set namespace toLibA
, and will instead try to resolveB
as item ofLibB
, which would fail.Solution
I've updated
resolve_custom_types
fn to use customResolver
visitor which keeps track of namespace, updates it before entering a type from another namespace and resets it to previous value after type is processed.PR Checklist