Skip to content

Commit

Permalink
Merge pull request #16179 from GunnarFarneback/promote_op
Browse files Browse the repository at this point in the history
Add a promote_op method to solve #16164.
  • Loading branch information
timholy committed May 4, 2016
2 parents 5de52cf + b00f91b commit a0f4920
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
1 change: 1 addition & 0 deletions base/promotion.jl
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,7 @@ minmax(x::Real, y::Real) = minmax(promote(x, y)...)
# promote_op{R<:MyType,S<:MyType}(::typeof(*), ::Type{R}, ::Type{S}) = MyType{multype(R,S)}
promote_op(::Any) = (@_pure_meta; Bottom)
promote_op(::Any, T) = (@_pure_meta; T)
promote_op{T}(::Type{T}, ::Any) = (@_pure_meta; T)
promote_op{R,S}(::Any, ::Type{R}, ::Type{S}) = (@_pure_meta; promote_type(R, S))
promote_op(op, T, S, U, V...) = (@_pure_meta; promote_op(op, T, promote_op(op, S, U, V...)))

Expand Down
5 changes: 5 additions & 0 deletions test/broadcast.jl
Original file line number Diff line number Diff line change
Expand Up @@ -127,3 +127,8 @@ end
let a = Real[2, 2.0, 4//2] / 2.0
@test eltype(a) == Real
end

# issue 16164
let a = broadcast(Float32, [3, 4, 5])
@test eltype(a) == Float32
end

0 comments on commit a0f4920

Please sign in to comment.