-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Verbose type names can make error messages difficult to read #12401
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
Comments
Here's another example that showcases it well: const std = @import("std");
pub fn main() void {
var x = std.io.countingWriter(std.io.countingWriter(std.io.getStdOut().writer()));
y(x);
}
fn y(x: @TypeOf(std.io.countingWriter(std.io.bufferedWriter(std.io.getStdOut().writer())))) void {
_ = x;
}
Try reading that in a terminal and spot the difference. It's really hard.
So the issue here is that there's a type mismatch and it shows you the two types it has and the developer wants to know what's different between those two types and spot the difference.
With this alignment the difference is already a lot easier to spot. However with too small window sizes and too long types it will still cut off and we will have the same problem. Apart from that, we could try shortening the type names. One thing we could try is to limit the nesting when it's no longer important to see the other things inside the parentheses? Maybe like this (notice the ellipses at the end)?
This should give the dev enough info right? I don't know how viable this is though so someone else would have to say. |
And I wonder where else we have such cases where there's a mismatch and you're shown two things and you have to spot the difference. Maybe we can generalize the solution then. |
It would be nice if zig could point to where they differ given that types should now (iirc) all have a normalized name. Thus the above:
becomes:
where the |
A type error within a function that has the following signature:
Produces an error message like this:

The expected type name is:
I don't have a specific solution in mind
The text was updated successfully, but these errors were encountered: