diff --git a/ext/UnitfulExt.jl b/ext/UnitfulExt.jl index 01139ac..929a92f 100644 --- a/ext/UnitfulExt.jl +++ b/ext/UnitfulExt.jl @@ -52,14 +52,14 @@ for PT in MonteCarloMeasurements.ParticleSymbols end function Base.$f(p::$PT{T,N}, y::Quantity{S,D,U}) where {S, D, U, T <: Number, N} - QT = Base.promote_op($op, T, typeof(y)) - $PT{QT,N}($(op).(p.particles, y)) + parts = $(op).(p.particles, y) + $PT{eltype(parts),N}(parts) end # Below is just the reverse signature of above function Base.$f(y::Quantity{S,D,U}, p::$PT{T,N}) where {S, D, U, T <: Number, N} - QT = Base.promote_op($op, typeof(y), T) - $PT{QT,N}($(op).(y, p.particles)) + parts = $(op).(y, p.particles) + $PT{eltype(parts),N}(parts) end function Base.$f(p::$PT, y::Unitful.FreeUnits) diff --git a/test/test_unitful.jl b/test/test_unitful.jl index c52106d..3dd38d2 100644 --- a/test/test_unitful.jl +++ b/test/test_unitful.jl @@ -1,4 +1,4 @@ -using Unitful +using Unitful, Test, MonteCarloMeasurements function unitful_testfunction(Vi) if Vi ≤ 0.0u"V" return 0.0u"V" @@ -76,6 +76,10 @@ register_primitive(unitful_testfunction) # must be outside testset y = z * x @test y isa PT{<:Quantity} @test ustrip(u"cm", x*y) isa PT{Float64} + + y = x * z + @test y isa PT{<:Quantity} + @test ustrip(u"cm", x*y) isa PT{Float64} end end