Skip to content

fix(sol-macro): derive namespaced custom types - #1152

Merged
DaniPopes merged 1 commit into
alloy-rs:mainfrom
figtracer:fig/derive-namespaced-types
Jul 16, 2026
Merged

DaniPopes merged 1 commit into
alloy-rs:mainfrom
figtracer:fig/derive-namespaced-types

Conversation

@figtracer

@figtracer figtracer commented Jul 16, 2026 •

Copy link
Copy Markdown
Collaborator

Motivation

#[sol(all_derives)] skips the built-in derives on events that reference a namespace-qualified struct when that struct contains an unqualified sibling custom type. The eligibility walk resolves the nested field from the consuming namespace instead of the namespace where the outer struct was declared. This is visible in generated Foundry bindings as an empty derive list on the event.

Addresses foundry-rs/foundry#10353.

Solution

Return the namespace selected during item lookup and carry it through the recursive Default and built-in trait eligibility checks. This keeps the existing nominal rules intact, including enums not implementing Default directly while dynamic arrays of enums can. The regression covers the original nested struct case, the enum distinction, and the generated contract event enum.

@figtracer
figtracer marked this pull request as ready for review July 16, 2026 13:52
@github-project-automation github-project-automation Bot moved this to Reviewed in Alloy Jul 16, 2026
@DaniPopes
DaniPopes enabled auto-merge (squash) July 16, 2026 14:13
@DaniPopes
DaniPopes disabled auto-merge July 16, 2026 14:15
@DaniPopes
DaniPopes merged commit 24e3053 into alloy-rs:main Jul 16, 2026
30 checks passed
@github-project-automation github-project-automation Bot moved this from Reviewed to Done in Alloy Jul 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants