symengine / SymEngine.jl

Julia wrappers of SymEngine
MIT License
192 stars 43 forks source link

Regression: Multiplication of `Basic`, `Rational`, and `Vector{Basic}` fails #259

Closed ranocha closed 1 year ago

ranocha commented 1 year ago

I observed a regression when updating from SymEngine.jl v0.8.7 to v0.9.0. The following code works well in the old version

julia> using Pkg; Pkg.activate(temp = true); Pkg.add(name = "SymEngine", version = v"0.8.7")

julia> using SymEngine

julia> a, b, c = symbols("a b c")
(a, b, c)

julia> a * [b, c]
2-element Vector{Basic}:
 a*b
 a*c

julia> a * 1//3 * [b, c]
2-element Vector{Basic}:
 (1/3)*a*b
 (1/3)*a*c

However, it fails as follows in the new version:

julia> using Pkg; Pkg.activate(temp = true); Pkg.add(name = "SymEngine", version = v"0.9.0")

julia> using SymEngine

julia> a, b, c = symbols("a b c")
(a, b, c)

julia> a * [b, c]
2-element Vector{Basic}:
 a*b
 a*c

julia> a * 1//3 * [b, c]
ERROR: MethodError: Cannot `convert` an object of type Vector{Basic} to an object of type Basic

Closest candidates are:
  convert(::Type{T}, ::Base.TwicePrecision) where T<:Number
   @ Base twiceprecision.jl:273
  convert(::Type{T}, ::AbstractChar) where T<:Number
   @ Base char.jl:185
  convert(::Type{T}, ::CartesianIndex{1}) where T<:Number
   @ Base multidimensional.jl:127
  ...

Stacktrace:
 [1] Basic(x::Vector{Basic})
   @ SymEngine ~/.julia/packages/SymEngine/ND5HB/src/types.jl:93
 [2] *(::Basic, ::Rational{Int64}, ::Vector{Basic})
   @ SymEngine ~/.julia/packages/SymEngine/ND5HB/src/mathops.jl:66
 [3] top-level scope
   @ REPL[5]:1

I noticed this in https://github.com/ranocha/BSeries.jl/pull/108

isuruf commented 1 year ago

I guess https://github.com/symengine/SymEngine.jl/pull/246 is the culprit.