You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Dug into this — the trigger is the two overloaded Swap events, not the field types. Minimal repro (no JSON needed):
sol!{
#[sol(all_derives)]
contract Pool{
event Swap(address indexed s, uint256 a);
event Swap(address indexed s, uint256 a, uint256 b);}}// Pool::PoolEvents then lacks Debug / Eq / Hash (PartialEq + Clone are still there).
A single (non-overloaded) event with the same field types derives fine, so it is specifically the overload.
Root cause (in sol-macro-expander):
For the events enum, ToExpand::Events::to_data sets variants to the overloaded names (overloaded_name, e.g. Swap_0 / Swap_1) and types: None, so generate_enum uses those overloaded idents as the variant types for type_derives.
type_derives (all_derives branch) only adds [Debug, PartialEq, Eq, Hash] when can_derive_builtin_traits returns true for every variant type.
can_derive_builtin_traits (ty.rs) does Type::Custom(name) => match self.try_item(name), but the overloaded idents (Swap_0) are not registered in all_items (the events live there under the original name Swap), so try_item returns None and it falls through to _ => false.
derive_others becomes false, so Debug/Eq/Hash are dropped. Clone/PartialEq survive because they are added by the events path separately, which is why the failure looks partial.
Same mechanism affects overloaded errors, and it is the same reason the *Calls enum does not pick up all_derives builtin traits (related to alloy-rs/alloy#3857 / alloy-rs/alloy#1124).
Possible fix directions:
Make can_derive_builtin_traits resolve the overloaded variant name back to the underlying item, or
Compute the enum's derivability from the underlying event/error/function param types (which are available in to_data) instead of re-resolving the synthetic variant idents.
Happy to put up a PR — do you have a preference between (1) and (2)? I’d lean (2) since it fixes calls/errors/events uniformly without special-casing name resolution.
If alloy-rs/alloy#2 unify the derive stuff into single place, then alloy-rs/alloy#2 should be the right
thing to do. I do notice to use other attribute to explicitly derive
builtin traits don’t have such a issue.
Agreed — that's what #1118 does: it computes the enum's derivability from the underlying param types in one place, instead of re-resolving the synthetic overloaded variant idents. It's approved, so this should be fixed once it lands.
Activity
satyakwok commentedon Jun 11, 2026
Dug into this — the trigger is the two overloaded
Swapevents, not the field types. Minimal repro (no JSON needed):A single (non-overloaded) event with the same field types derives fine, so it is specifically the overload.
Root cause (in
sol-macro-expander):ToExpand::Events::to_datasetsvariantsto the overloaded names (overloaded_name, e.g.Swap_0/Swap_1) andtypes: None, sogenerate_enumuses those overloaded idents as the variant types fortype_derives.type_derives(all_derives branch) only adds[Debug, PartialEq, Eq, Hash]whencan_derive_builtin_traitsreturns true for every variant type.can_derive_builtin_traits(ty.rs) doesType::Custom(name) => match self.try_item(name), but the overloaded idents (Swap_0) are not registered inall_items(the events live there under the original nameSwap), sotry_itemreturnsNoneand it falls through to_ => false.derive_othersbecomesfalse, soDebug/Eq/Hashare dropped.Clone/PartialEqsurvive because they are added by the events path separately, which is why the failure looks partial.Same mechanism affects overloaded errors, and it is the same reason the
*Callsenum does not pick upall_derivesbuiltin traits (related to alloy-rs/alloy#3857 / alloy-rs/alloy#1124).Possible fix directions:
can_derive_builtin_traitsresolve the overloaded variant name back to the underlying item, orto_data) instead of re-resolving the synthetic variant idents.Happy to put up a PR — do you have a preference between (1) and (2)? I’d lean (2) since it fixes calls/errors/events uniformly without special-casing name resolution.
Jinwei1987 commentedon Jun 14, 2026
satyakwok commentedon Jun 14, 2026
Agreed — that's what #1118 does: it computes the enum's derivability from the underlying param types in one place, instead of re-resolving the synthetic overloaded variant idents. It's approved, so this should be fixed once it lands.