From ae1f01a98578594f51774d04f15fccd06db1a523 Mon Sep 17 00:00:00 2001 From: Kristoffer Carlsson Date: Wed, 2 Dec 2026 13:39:54 +0100 Subject: [PATCH] Do not rely on `@nospecialize` argument names being unhygienic The kwcall method of `@non_differentiable` declared its gensym'd kwargs argument unescaped inside `@nospecialize(...)` but referred to it from escaped code. That only works because the flisp macro expander does not rename arguments wrapped in `@nospecialize`, and fails on Julia 1.15. Assisted-by: Claude Code (Fable 5.2) --- src/rule_definition_tools.jl | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/rule_definition_tools.jl b/src/rule_definition_tools.jl index f3e19cd6f..5faf44dcd 100644 --- a/src/rule_definition_tools.jl +++ b/src/rule_definition_tools.jl @@ -424,11 +424,13 @@ function _nondiff_frule_expr(__source__, primal_sig_parts, primal_invoke) return @strip_linenos quote # Manually defined kw version to save compiler work. See explanation in rules.jl function (::Core.kwftype(typeof(ChainRulesCore.frule)))( - @nospecialize($kwargs::Any), + $(esc(kwargs))::Any, frule::typeof(ChainRulesCore.frule), @nospecialize(::Tuple), $(map(esc, primal_sig_parts)...), ) + # `esc` is not accepted inside `@nospecialize(arg)` in a signature + $(Expr(:meta, :nospecialize, kwargs)) return ($(esc(_with_kwargs_expr(primal_invoke, kwargs))), NoTangent()) end function ChainRulesCore.frule(