Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "Mooncake"
uuid = "da2b9cff-9c12-43a0-ae48-6db2b0edb7d6"
authors = ["Will Tebbutt, Hong Ge, and contributors"]
version = "0.4.148"
version = "0.4.149"

[deps]
ADTypes = "47edcb42-4c32-4615-8424-f2b9edc5f35b"
Expand Down
10 changes: 5 additions & 5 deletions src/tools_for_rules.jl
Original file line number Diff line number Diff line change
Expand Up @@ -282,9 +282,8 @@ function _zero_derivative_impl(ctx, sig, mode)
# which does not escape the mode argument. This will work even if the names `Mooncake`
# or `Mooncake.Mode` are not available in the scope which calls this macro.
is_primitive_ex = quote
const M = $mode
function Mooncake.is_primitive(
::Type{$(esc(ctx))}, ::Type{<:M}, ::Type{<:$(esc(sig))}
::Type{$(esc(ctx))}, ::Type{<:($(esc(mode)))}, ::Type{<:($(esc(sig)))}
Comment on lines 282 to +286
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment above says to not escape mode, so I wonder if $(mode) would be better?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I won't have time for this in the next few days. Please feel free to take over and merge it.

)
return true
end
Expand Down Expand Up @@ -605,7 +604,9 @@ function _from_chainrules_impl(ctx, sig::Expr, has_kwargs::Bool, mode)
kw_sig = where_params === nothing ? kw_sig : Expr(:where, kw_sig, where_params...)
# Type M will be available later on, and will be the mode type.
kw_is_primitive = quote
function Mooncake.is_primitive(::Type{$(esc(ctx))}, ::Type{<:M}, ::Type{<:$kw_sig})
function Mooncake.is_primitive(
::Type{$(esc(ctx))}, ::Type{<:($(esc(mode)))}, ::Type{<:$kw_sig}
)
return true
end
end
Expand Down Expand Up @@ -634,9 +635,8 @@ function _from_chainrules_impl(ctx, sig::Expr, has_kwargs::Bool, mode)
end

return quote
const M = $mode
function Mooncake.is_primitive(
::Type{$(esc(ctx))}, ::Type{<:M}, ::Type{<:($(esc(sig)))}
::Type{$(esc(ctx))}, ::Type{<:($(esc(mode)))}, ::Type{<:($(esc(sig)))}
)
return true
end
Expand Down
Loading