Inconsistency between Core.Compiler.return_type and Test.@inferred

The Any here indicates a total failure of the return type inference:

julia> f(op::Op, a, b) where {Op} = op(a, b)
f (generic function with 1 method)

julia> Core.Compiler.return_type(f, Tuple{typeof(=>),Int,Int})

Why does @inferred not throw, then:

julia> using Test

julia> @inferred f(=>, 3, 7)
3 => 7

This is the problem: => is actually just Pair, a type, so typeof just returns DataType.

julia> Core.Compiler.return_type(f, Tuple{Type{Pair},Int,Int})
Pair{Int64, Int64}