Skip to content

Type promotion causes stack overflow #94

Open
@kaandocal

Description

@kaandocal

The following causes a StackOverflowError:

using DynamicPolynomials

promote_type(Any, Polynomial{true,Any})

Here Any can be replaced by various types. Output:

ERROR: StackOverflowError:
Stacktrace:
 [1] promote_result(#unused#::Type, #unused#::Type, #unused#::Type{Any}, #unused#::Type{DynamicPolynomials.Polynomial{true, Any}})
   @ Base ./promotion.jl:247

What happens is that promote_rule(Any, Polynomial{true,Any}) returns Any and promote_rule(Polynomial{true,Any}, Any) returns Polynomial{true,Any}, and promote_result keeps calling itself with the exact same type arguments...

This originally came up trying to run MomentClosure.jl with SymbolicUtils version >= 0.12 (expanding some polynomial expressions). I'm currently trying to figure out the intended semantics behind this and trying to find a fix but I thought it might be useful to point it out :)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions