Skip to content

Commit 3afa92f

Browse files
authored
fix the Base.dataids method (#40)
* For types where the element can be mutated, which is only `Box`, the fallback defined in `Base` should be OK. * For types where the element can not be mutated, just return an empty tuple. Fixes #34
1 parent fbacb1a commit 3afa92f

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

src/ZeroDimensionalArrays.jl

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,16 @@ mutable struct BoxConst{T} <: AbstractArray{T, 0}
2929
end
3030
end
3131

32-
const ZeroDimensionalArray = Union{
32+
const ZeroDimensionalArrayCanNotMutateElement = Union{
3333
ZeroDimArray,
34-
Box,
3534
BoxConst,
3635
}
3736

37+
const ZeroDimensionalArray = Union{
38+
ZeroDimensionalArrayCanNotMutateElement,
39+
Box,
40+
}
41+
3842
function type_to_constructor_function(::Type{T}) where {T <: ZeroDimensionalArray}
3943
local ret
4044
if T <: ZeroDimArray
@@ -158,8 +162,8 @@ end
158162

159163
# https://github.com/JuliaLang/julia/issues/51753
160164
if isdefined(Base, :dataids) && hasmethod(Base.dataids, Tuple{Box{Float32}})
161-
function Base.dataids(a::ZeroDimensionalArray)
162-
Base.dataids(only(a))
165+
Base.@nospecializeinfer function Base.dataids((@nospecialize a::ZeroDimensionalArrayCanNotMutateElement),)
166+
()
163167
end
164168
end
165169

0 commit comments

Comments
 (0)