diff --git a/src/arrays.jl b/src/arrays.jl index ce6504eae..4915b94fb 100644 --- a/src/arrays.jl +++ b/src/arrays.jl @@ -99,6 +99,14 @@ function arguments(a::ArrayOp) arguments(a.term) end +function similarterm(a::ArrayOp, f, args, type; metadata=nothing) + res = f(args...) + if res isa Symbolic && metadata !== nothing + res = SymbolicUtils.metadata(res, metadata) + end + res +end + function Base.isequal(a::ArrayOp, b::ArrayOp) a === b && return true isequal(a.shape, b.shape) && diff --git a/test/arrays.jl b/test/arrays.jl index 24497a0a1..98da87837 100644 --- a/test/arrays.jl +++ b/test/arrays.jl @@ -413,3 +413,8 @@ end @test_throws BoundsError k[-1] @test_throws BoundsError k[4] end + +@testset "similar term #991" begin + @variables x[1:3] + @test substitute(x[1:2] .* x[3], Dict(x => [1, 2, 3])) == [3, 6] +end \ No newline at end of file