diff --git a/src/promote.jl b/src/promote.jl index f739611..e01a9a9 100644 --- a/src/promote.jl +++ b/src/promote.jl @@ -42,6 +42,30 @@ function SA.promote_with_map( return Polynomial{V,M,T}(copy(p.a), new_x), map end +function MP.promote_rule_constant( + ::Type{Any}, + ::Type{<:DMonomialLike{V,M}}, +) where {V,M} + return Any +end +function MP.promote_rule_constant( + ::Type{Any}, + ::Type{_Term{V,M,T}}, +) where {V,M,T} + return Any +end +function MP.promote_rule_constant( + ::Type{Any}, + ::Type{_Term{V,M,T}}, +) where {V,M,T} + return Any +end +function MP.promote_rule_constant( + ::Type{Any}, + ::Type{<:TermPoly{V,M,T}}, +) where {V,M,T} + return Any +end function MP.promote_rule_constant( ::Type{T}, ::Type{<:DMonomialLike{V,M}}, diff --git a/test/runtests.jl b/test/runtests.jl index 36f20ea..9ff257a 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -91,4 +91,11 @@ import DynamicPolynomials end end +@testset "Issue #166: promote_operation with Any" begin + DynamicPolynomials.@polyvar x + V = typeof(x) + @test promote_type(V, Any) == Any + @test promote_type(typeof(x/2), Any) == Any +end + include("mvp.jl")