Skip to content

Commit 8b2e04a

Browse files
S-D-Rmaleadt
authored andcommitted
Add version check for using 'eachslice'
1 parent 81d4546 commit 8b2e04a

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/core/value/constant.jl

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,8 +128,11 @@ function ConstantArray(typ::LLVMType, data::AbstractArray{T,N}) where {T<:Consta
128128
return ConstantArray(API.LLVMConstArray(typ, Array(data), length(data)))
129129
end
130130

131-
# FIXME: once we drop support for julia 1.0, we can use `eachslice(data, dims=1)` instead of this monstrosity
132-
ca_vec = map(x->ConstantArray(typ, x), (view(data, i, ntuple(d->(:), N-1)...) for i in axes(data, 1)))
131+
if VERSION >= v"1.1"
132+
ca_vec = map(x->ConstantArray(typ, x), eachslice(data, dims=1))
133+
else
134+
ca_vec = map(x->ConstantArray(typ, x), (view(data, i, ntuple(d->(:), N-1)...) for i in axes(data, 1)))
135+
end
133136
ca_typ = llvmtype(first(ca_vec))
134137

135138
return ConstantArray(API.LLVMConstArray(ca_typ, ca_vec, length(ca_vec)))

0 commit comments

Comments
 (0)