From b00f91b71bc5e55fe9db7a1dcb1db477eb76320e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gunnar=20Farneb=C3=83=C2=A4ck?= Date: Tue, 3 May 2016 16:23:48 +0200 Subject: [PATCH] Add a promote_op method to solve #16164. --- base/promotion.jl | 1 + test/broadcast.jl | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/base/promotion.jl b/base/promotion.jl index af38a41118235..1ca5530a7b828 100644 --- a/base/promotion.jl +++ b/base/promotion.jl @@ -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...))) diff --git a/test/broadcast.jl b/test/broadcast.jl index a3904ecc9a399..4bf1260b759e5 100644 --- a/test/broadcast.jl +++ b/test/broadcast.jl @@ -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