@@ -11,16 +11,23 @@ function promote_operation_fallback(op::Function, x::Type{<:AbstractArray}, y::T
11
11
# We replace it by a more helpful error here.
12
12
error (" `promote_operation($op , $x , $y )` not implemented yet, please report this." )
13
13
end
14
- function promote_operation_fallback (:: typeof (/ ), :: Type{S} , :: Type{T} ) where {S,T}
15
- return typeof (zero (S) / oneunit (T))
14
+
15
+ function promote_operation_fallback (
16
+ op:: Function ,
17
+ :: Type{S} ,
18
+ :: Type{T} ,
19
+ ) where {S,T}
20
+ U = Base. promote_op (op, S, T)
21
+ return return U == Union{} ? typeof (op (oneunit (S), oneunit (T))) : U
16
22
end
17
23
# Julia v1.0.x has trouble with inference with the `Vararg` method, see
18
24
# https://travis-ci.org/jump-dev/JuMP.jl/jobs/617606373
19
- function promote_operation_fallback (op:: F , :: Type{S} , :: Type{T} ) where {F<: Function ,S,T}
20
- return typeof (op (zero (S), zero (T)))
21
- end
22
- function promote_operation_fallback (op:: F , args:: Vararg{Type,N} ) where {F<: Function ,N}
23
- return typeof (op (zero .(args)... ))
25
+ function promote_operation_fallback (
26
+ op:: F ,
27
+ args:: Vararg{Type,N} ,
28
+ ) where {F<: Function ,N}
29
+ U = Base. promote_op (op, args... )
30
+ return return U == Union{} ? typeof (op (oneunit .(args)... )) : U
24
31
end
25
32
promote_operation_fallback (:: typeof (* ), :: Type{T} ) where {T} = T
26
33
function promote_operation_fallback (
0 commit comments