Skip to content

Fix @adapt_structure for modules that only import the macro.#109

Merged
maleadt merged 1 commit into
masterfrom
tb/fix
Apr 10, 2026
Merged

Fix @adapt_structure for modules that only import the macro.#109
maleadt merged 1 commit into
masterfrom
tb/fix

Conversation

@maleadt
Copy link
Copy Markdown
Member

@maleadt maleadt commented Apr 10, 2026

The previous fix used esc(quote ... end), which made the generated code resolve Adapt.adapt_structure in the caller's module. This broke modules that do using Adapt: @adapt_structure (e.g. DataInterpolationsND) because Adapt itself is not bound there.

Switch to value-interpolating the Adapt module directly via $Adapt (and $$Adapt to reach into the inner quote that runs at codegen time). The function-argument names to and obj are escaped explicitly so hygiene does not gensym them — that keeps them matching the literal :to/:obj symbols inside the inner quote. The resulting IR is unchanged (direct getfield + %new).

Fixes #108

The previous fix used `esc(quote ... end)`, which made the generated
code resolve `Adapt.adapt_structure` in the caller's module. This broke
modules that do `using Adapt: @adapt_structure` (e.g. DataInterpolationsND)
because `Adapt` itself is not bound there.

Switch to value-interpolating the Adapt module directly via `$Adapt`
(and `$$Adapt` to reach into the inner quote that runs at codegen time).
The function-argument names `to` and `obj` are escaped explicitly so
hygiene does not gensym them — that keeps them matching the literal
`:to`/`:obj` symbols inside the inner quote. The resulting IR is
unchanged (direct getfield + %new).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@maleadt maleadt merged commit 650a7b6 into master Apr 10, 2026
21 of 22 checks passed
@maleadt maleadt deleted the tb/fix branch April 10, 2026 17:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

New release broke DataInterpolationsND

1 participant