stack traces: only print relevant aspects of parametric types #45795
Labels
display and printing
Aesthetics and correctness of printed representations of objects.
error handling
Handling of exceptions by Julia or the user
Offshoot of #45687. The idea is to limit what aspects of a type in a stack trace we print to only the parts of the type that are relevant to dispatch. This can be computed as a combination of concrete types of the arguments and the type of the method that is called. For example, if slot in a method is
AbstractArray
and the argument isVector{SomeLargeType}
then we could just printVector
.The general concept is to only print as much detail about a type as is required to understand the dispatch choice. It's a bit tricky to make this precise, however. Type intersection isn't useful since the concrete argument type is always a subtype of the method parameter. If the concrete argument type is
C
and the parameter type isA
then what we want to print is a typeB
such thatA >: B >: C
.Slightly more generally we can say the same about
A
,B
andC
as method signature tuple types, not just individual argument slots. For example, suppose we have a method that looks like(AbstractDict{T, <:Any}, AbstractVector{T}) where T
and the actual call has types(Dict{String, SomeLargeType}, Vector{String})
then we'd want to print(Dict{String}, Vector{String})
. We want to includeString
because it's necessary for the type to be the same across the two arguments in order for the method to match; we don't need to includeSomeLargeType
because it's irrelevant to the method matching. So we need some kind of bounded widening of types by walking up the type lattice from a concrete point to a broader type that is still within the argument type.The text was updated successfully, but these errors were encountered: