Skip to content

Commit afd0eac

Browse files
authored
Fix inferrence regression on nightly for has_dimnames (#252)
1 parent 77146e8 commit afd0eac

File tree

2 files changed

+5
-7
lines changed

2 files changed

+5
-7
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name = "ArrayInterface"
22
uuid = "4fba245c-0d91-5ea0-9b3e-6abc04ee57a9"
3-
version = "5.0.4"
3+
version = "5.0.5"
44

55
[deps]
66
Compat = "34da2185-b29b-5c13-b0c7-acf172513d20"

src/dimensions.jl

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -147,17 +147,15 @@ function to_parent_dims(::Type{T}, ::StaticInt{dim}) where {T,dim}
147147
end
148148
end
149149

150-
_nunderscore(::Val{N}) where {N} = ntuple(Compat.Returns(:_), Val(N))
151-
152150
"""
153151
has_dimnames(::Type{T}) -> StaticBool
154152
155153
Returns `static(true)` if `x` has on or more named dimensions. If all dimensions correspond
156154
to `static(:_)`, then `static(false)` is returned.
157155
"""
158-
Compat.@constprop :aggressive has_dimnames(x) = static(_is_named(known_dimnames(x)))
159-
_is_named(x::NTuple{N,Symbol}) where {N} = x !== _nunderscore(Val(N))
160-
_is_named(::Any) = true
156+
@inline function has_dimnames(x)
157+
static(known_dimnames(x) !== ntuple(Compat.Returns(:_), Val(ndims(x))))
158+
end
161159

162160
"""
163161
known_dimnames(::Type{T}) -> Tuple{Vararg{Union{Symbol,Nothing}}}
@@ -170,7 +168,7 @@ have a name.
170168
known_dimnames(x) = known_dimnames(typeof(x))
171169
known_dimnames(::Type{T}) where {T} = _known_dimnames(T, parent_type(T))
172170
_known_dimnames(::Type{T}, ::Type{T}) where {T} = _unknown_dimnames(Base.IteratorSize(T))
173-
_unknown_dimnames(::Base.HasShape{N}) where {N} = _nunderscore(Val(N))
171+
_unknown_dimnames(::Base.HasShape{N}) where {N} = ntuple(Compat.Returns(:_), Val(N))
174172
_unknown_dimnames(::Any) = (:_,)
175173
function _known_dimnames(::Type{C}, ::Type{P}) where {C,P}
176174
eachop(_inbounds_known_dimname, to_parent_dims(C), known_dimnames(P))

0 commit comments

Comments
 (0)