Skip to content

Commit

Permalink
Avoid StackOverflow in promote_type with Any
Browse files Browse the repository at this point in the history
  • Loading branch information
dlfivefifty committed Dec 5, 2024
1 parent 29c1647 commit a9fa0cb
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 1 deletion.
7 changes: 7 additions & 0 deletions src/promote.jl
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,13 @@ function promote_rule_constant(
return term_type(TT, promote_type(S, T))
end

function promote_rule_constant(
::Type{Any},
TT::Type{<:AbstractTermLike{T}},
) where {T}
return Any
end

# PolynomialLike
Base.promote_rule(::Type{PT}, ::Type{PT}) where {PT<:_APL} = PT
function Base.promote_rule(PS::Type{<:_APL}, PT::Type{<:_APL})
Expand Down
2 changes: 1 addition & 1 deletion test/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@ Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
TypedPolynomials = "afbbf031-7a57-5f58-a1b9-b774a0fad08d"

[compat]
DynamicPolynomials = "0.5"
DynamicPolynomials = "0.5, 0.6.2"
TypedPolynomials = "0.4"
6 changes: 6 additions & 0 deletions test/promote.jl
Original file line number Diff line number Diff line change
Expand Up @@ -171,3 +171,9 @@ end
__promote_prod(PXY, PXY, PXY)
end
end

@testset "promote_operation with Any" begin
Mod.@polyvar x
V = typeof(x)
@test promote_type(V, Any) == Any
end
1 change: 1 addition & 0 deletions test/test/Project.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[deps]

0 comments on commit a9fa0cb

Please sign in to comment.