Julia only gives “type errors” when you evaluate the code that exhibits the problem. The reason 1 + "hi"
throws immediately is because when you evaluate that, it’s already a problem. When you evaluate sin ∘ string
there’s no problem – the problem only occurs when you actually try to call that composite function on something. And the way Julia works, maybe it doesn’t – this is a perfectly valid if questionably useful program:
julia> ss = sin ∘ string
(::#55) (generic function with 1 method)
julia> Base.string(n::Int) = n
julia> ss(123)
-0.45990349068959124
You can’t generally know if a function composition is “well typed” when it occurs. You can only know that when it runs. We could potentially have a subset of behaviors which, if you follow them, allow compile-time checking that a problem doesn’t have any method errors, but that’s a project for some time in the future (post-1.0).