-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
stack traces: only print relevant aspects of parametric types #45795
Comments
Not exactly the same idea, but an (easy?) interim option might be to just report the written type signature of the relevant method (ie, the types in the method definition). Or, one step more sophisticated, to replace the written types in the signature with the concrete input types of the call to the same parameter depth as the definition. |
That is a bit opposite to the intent of the code currently, which is to show the part of the stack traces that cannot be seen directly from looking at the source code. The declaration is completely uninteresting, since you can always look at the source file if you want that |
Idea for how to compute |
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: