From 60367b145bc28c57607f8006e67e9407f4368518 Mon Sep 17 00:00:00 2001 From: Jameson Nash Date: Mon, 5 Jun 2017 22:30:50 -0400 Subject: [PATCH 1/2] avoid 4-arg promote_type Base can't infer it --- src/Promotion.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Promotion.jl b/src/Promotion.jl index 3fb5b7dc..3b6af43a 100644 --- a/src/Promotion.jl +++ b/src/Promotion.jl @@ -161,7 +161,7 @@ function Base.promote_rule{S1,S2,D,U1,U2}(::Type{Quantity{S1,D,U1}}, p = promote_unit(U1(), U2()) numtype = promote_type(S1,S2, - typeof(convfact(p,U1())), typeof(convfact(p,U2()))) + promote_type(typeof(convfact(p,U1())), typeof(convfact(p,U2())))) if !isunitless(p) if U1 <: ContextUnits && U2 <: ContextUnits up1 = upreferred(U1()) From 9a8dd684b011f574ea6bb0c23d3dd5893e1667f1 Mon Sep 17 00:00:00 2001 From: Jameson Nash Date: Mon, 5 Jun 2017 22:35:02 -0400 Subject: [PATCH 2/2] isunitless: use `is` is instead of `==` this is inferrable --- src/Unitful.jl | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Unitful.jl b/src/Unitful.jl index f6ff95a1..048ee688 100644 --- a/src/Unitful.jl +++ b/src/Unitful.jl @@ -44,7 +44,8 @@ const promotion = Dict{Symbol,Unit}() include("User.jl") const NoUnits = FreeUnits{(), Dimensions{()}}() const NoDims = Dimensions{()}() -@inline isunitless{N}(::Units{N}) = N == () +isunitless(::Units) = false +isunitless(::Units{()}) = true (y::FreeUnits)(x::Number) = uconvert(y,x) (y::ContextUnits)(x::Number) = uconvert(y,x)