-
-
Notifications
You must be signed in to change notification settings - Fork 418
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 error message for match on structs #3746
Conversation
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.
Nice work!
@ergl should this be merged? also, do you think this deserves a changelog entry and release notes? |
@SeanTAllen Yes, I think it's ready to be merged. As for release notes, sound good, this is probably worth mentioning. |
Hi @ergl, The changelog - changed label was added to this pull request; all PRs with a changelog label need to have release notes included as part of the PR. If you haven't added release notes already, please do. Release notes are added by creating a uniquely named file in the The basic format of the release notes (using markdown) should be:
Thanks. |
This commit can be merged once @ergl adds release notes. I'm adding a "do not merge" label until then. |
@ergl this has a merge conflict that will need to be resolved in addition to the addition of release notes. |
Since a struct doesn't have a type descriptor, it's impossible to match against it, unless it's exactly the same struct type. Before, the return type of matchtype.c:is_matchtype didn't convey enough information to the caller about the reason why two types couldn't match. In most cases, this is due to reference capabilities, so that's what the error message shows. By distinguishing the specific case of a match failure due to lack of type descriptor, the compiler can give a friendlier error message to the user.
Rebased and added release notes. I've added an example of the new error message in the release notes, but perhaps that's too much? I'm willing to trim it back to just the first paragraph. |
@ergl looks good to me |
Since a struct doesn't have a type descriptor, it's impossible to match
against it, unless it's exactly the same struct type. Before, the
return type of matchtype.c:is_matchtype didn't convey enough information
to the caller about the reason why two types couldn't match. In most
cases, this is due to reference capabilities, so that's what the error
message shows.
By distinguishing the specific case of a match failure due to lack of
type descriptor, the compiler can give a friendlier error message to the
user.
This fixes #2000 and fixes #3565, and mostly follows the approach described by @jemc on the second issue.