-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
Shorten coercion error messages by eliding non-conflicting parts of types #20576
Conversation
I like the change, though for certain scenarios it might be helpful to see the elided part as well; |
Do you have an example at hand of where you would need the rest of the type? |
I agree with @rohlem -- there should be a
I can think of some esoteric cases, but they are besides the point. We should not omit key information about the error (the types in a type mismatch!) in the name of compactness. |
Full agree on the length check and ASCII. The unicode ellipsis was provisional to distinguish from e.g. the
Is it actually key information though? If it isn't, we shouldn't be spamming the output with it. |
The main scenario I was thinking of would be a generic function (accepting |
@rohlem excellent point, thanks |
So something like this? fn funcB(x: u32, y: u32, z: u8) u32 { return x + y + z; }
test { _ = @as(fn(u32, u64, u8) u32, funcB); }
Imagine this only kicking in for much longer types names than |
draft status, no updates in 30+ days |
Attempt to address #12401 by printing only the components of types that are mismatched. As far as I can tell, Rustc and Clang do similar things to prevent error message blowup.
So far, this only covers Type.print(), and results in messages like this:
I made this draft to check to check whether this sounds like a decent strategy for Zig error messages. If you think it is, I'll expand this to cover the actually really long type names mentioned in #12401, which are produced by createAnonymousDeclNamed for NameStrategy.func. To solve that, I will probably need to preserve the function name and argument values in the anonymous type's Decl and then implement similar diffing logic in Value.print().