Description
@code_typed
(and code_typed
) will sometimes report a different result than actually gets inferred if you call the function. For example:
julia> f1(x) = Base.typemax(x)
f1 (generic function with 1 method)
julia> @code_typed f1(Int)
CodeInfo(
1 ─ return 9223372036854775807
) => Int64
Here @code_typed
shows you fully specialized code, even though in reality this call will not be specialized (it will be a dynamic dispatch to typemax(Type{Int})
).
xref: the documentation change here: #32817
Note that
@code_typed
and friends will always show you specialized code, even if Julia
would not normally specialize that method call. You need to check the
[method internals](@ref ast-lowered-method) if you want to see whether specializations are generated
when argument types are changed.
Could we either change @code_typed
or add a flag to @code_typed
that will show you the code as julia would actually specialize it, instead of fully specialized to your argument type? :)