diff --git a/src/substitute.jl b/src/substitute.jl index 8fc980c69..828f88b14 100644 --- a/src/substitute.jl +++ b/src/substitute.jl @@ -51,11 +51,14 @@ Base.occursin(needle, haystack::Symbolic) = _occursin(needle, haystack) Base.occursin(needle::Symbolic, haystack) = _occursin(needle, haystack) function _occursin(needle, haystack) isequal(needle, haystack) && return true - if iscall(haystack) args = arguments(haystack) for arg in args - occursin(needle, arg) && return true + if needle isa Integer || needle isa AbstractFloat + isequal(needle, arg) && return true + else + occursin(needle, arg) && return true + end end end return false diff --git a/test/basics.jl b/test/basics.jl index 70cf1819f..024533c9e 100644 --- a/test/basics.jl +++ b/test/basics.jl @@ -184,6 +184,8 @@ end @test occursin(a, a + b) @test !occursin(sin(a), a + b + c) @test occursin(sin(a), a * b + c + sin(a^2 * sin(a))) + @test occursin(0.01, 0.01*a) + @test !occursin(0.01, a * b * c) end @testset "printing" begin