Skip to content

Commit 400fd9c

Browse files
authored
Merge pull request #332 from JuliaArrays/cjf/broadcast-inference-fix-simple
Workaround inference problem in round.(Int,v)
2 parents 715fefe + c6b7d1c commit 400fd9c

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

src/broadcast.jl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,12 @@ end
111111
end
112112
end
113113

114+
if VERSION < v"0.7.0-DEV"
115+
# Workaround for #329
116+
@inline function Base.broadcast(f, ::Type{T}, a::StaticArray) where {T}
117+
map(x->f(T,x), a)
118+
end
119+
end
114120

115121
################
116122
## broadcast! ##

test/mapreduce.jl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,9 @@
111111

112112
@test_throws DimensionMismatch broadcast(+, v1, @SMatrix [4 3 2 1; 5 6 7 8])
113113

114-
@test @inferred(broadcast(convert, Float64, v1)) == convert(Vector{Float64}, [2,4,6,8])
114+
@test @inferred(broadcast(convert, Float64, v1)) === SVector{4,Float64}(2,4,6,8)
115+
# issue 329
116+
@test @inferred(broadcast(round, Int, SVector(1.0,2.0))) === SVector{2,Int}(1,2)
115117

116118
@test @inferred(broadcast(-, v1)) === map(-, v1)
117119

0 commit comments

Comments
 (0)