Skip to content

Commit

Permalink
fix Base.Fix on nightly
Browse files Browse the repository at this point in the history
  • Loading branch information
CarloLucibello committed Oct 30, 2024
1 parent 4081043 commit 229691a
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions src/base.jl
Original file line number Diff line number Diff line change
@@ -1,21 +1,35 @@
## Opt-Out
###
### Opt-Out
###

@leaf Number
@leaf AbstractArray{<:Number}
@leaf AbstractString

## Fast Paths for common types
###
### Fast Paths for common types
###

functor(::Type{<:Tuple}, x) = x, identity
functor(::Type{<:NamedTuple{L}}, x) where L = NamedTuple{L}(map(s -> getproperty(x, s), L)), identity
functor(::Type{<:Dict}, x) = Dict(k => x[k] for k in keys(x)), identity
functor(::Type{<:AbstractArray}, x) = x, identity

## This may be a reasonable default for AbstractDict
## but is not guaranteed to be correct for all dict subtypes
# This may be a reasonable default for AbstractDict
# but is not guaranteed to be correct for all dict subtypes
function functor(::Type{D}, x) where {D<:AbstractDict}
return constructorof(D)([k => x[k] for k in keys(x)]...), identity
end

###
### Base Types requiring special handling
###

@static if VERSION >= v"1.12-DEV"
functor(::Type{<:Base.Fix{N}}, x) where N = (; x.f, x.x), y -> Base.Fix{N}(y.f, y.x)
end


###
### Array wrappers
###
Expand Down

0 comments on commit 229691a

Please sign in to comment.