-
-
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
Improve multiple error messages #20618
Conversation
src/Sema.zig
Outdated
=> try sema.errNote(src_loc, msg, "type has no guaranteed in-memory representation", .{}), | ||
.Array => try sema.errNote(src_loc, msg, "packed fields are ordered according to machine endianness, array elements are not", .{}), |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note that this is just a note on the packed structs cannot contain fields of type '[4]u32'
error message; adding "arrays are not allowed in packed structs" would be redundant.
The reason for it not being allowed, on the other hand, is rather subtle, and I think explaining it helps the user understand whether they want to solve the error by giving up packed-ness or array-ness. As far as I can tell, the reason #12547 is still open is that the status quo error message saying only "this isn't allowed" is not useful to new users.
b76224d
to
6624dc0
Compare
Fixes ziglang#14334: non-tuples are more common, and forgetting a type or name from a struct field is an easier mistake to make than adding a name to a tuple field. Also addresses ziglang#18597 (the specific case presented there, but not the general goal of that issue) by checking for mismatched parentheses after a parser error. Unclosed parens can cause otherwise much-more-cryptic errors.
Closes ziglang#12547: explain why arrays aren't allowed in packed structs. Closes ziglang#13832: improve error message for a common mistake on the LHS of the binary `!` operator.
While we can't cover every I/O function like this, lockStdErr covers std.debug.print and std.log.*, probably the most important places to leave a useful hint for newcomers to Zig.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm sorry but I do request these to be separate PRs. I went through the first 3 commits and saw things that I want to ask about in each one.
Fixes #12547.
Fixes #12829.
Fixes #13832.
Fixes #14334.
Fixes #16019.
Fixes #16702.
Fixes #14238.
None of these are particularly related, I can pull them into separate PRs if necessary.