-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Typechecker error messages don't use type abbreviations #828
Comments
Issue #828 This is not a full solution yet. To really get sane error messages, we'll also have to guess the name to apply to literals, which seems non-trivial.
Wow. I .. did not realize we got rid of cnames. Why? |
Marijn, I am somewhat concerned about your fix (which introduces the To demonstrate my point, I did a quick search through typeck for cases where we compared types using
We can fix this case (use unification) and we can convert any other places where (On the other hand, the existence of ty_var in the type hierarchy already means that comparing with I would rather see the names kept alongside the true, interned type as side information. This either means that we have a side table tracking, for each interned type, the shortest Alternatively, nominal records would basically make this problem go away with no effort at all (modulo objects). |
I suggest we simply fix code that uses |
Keep in mind, the unpack must be a deep unpack, because you might types like:
where Regarding user-visible names, yes, the names will be approximate. We could keep the mapping from canonical type to user-defined name per-module or, better yet, per-scope, but in the end we may not print the name precisely how the user wrote it. I am not concerned about this personally, it already happens with C compilers and typedef and so forth. Mildly annoying but best effort is probably good enough. |
Also, the intention of passing around |
That wouldn't cut it though, as you'd have to also make the values used internally in other types somehow carry the name. Let's try to replace equality tests with a unify-based compare and see how it performs. Yes, someone might introduce bugs by doing compares. I'm starting to feel that our code would actually perform better without interned types. We're unpacking them all over the place, again and again. Interning to reuse structure is a good idea, but the thing passed around might as well be an |
Yes, I agree that passing around the pair is a bad idea. I think having Anyway, if we keep this scheme, then yes we need to look through the Also, keep in mind that putting names into the types does not produce
yields the not-particularly-helpful error message |
Also: I am inclined to agree that there are better ways to represent types than what we're doing now... interning to an |
Also, re-reading your previous comment, I see that you wanted the stringified version of a type to be based on the source of the type, and not on the module where the error or type mismatch occurs. I am not sure this is desirable at all! I usually expect the type to be written in terms of the line where the error message is pointing. |
All that said, I know I am complaining a lot, but ultimately I am not completely opposed to this fix, although I am not persuaded it's the best approach for the reasons I enumerated. Still, almost anything is better than the current situation, as long as it's not buggy.. |
I consider the added complexity not justified at this point, and it interacts badly with the patches for issue #828. Feel free to discuss.
The above patch fixes the way method types (and a few other things) are compared to use proper unification. As for having different types with the same name in different modules, I think we should use the full path of the definition in error messages to handle that. |
Looks good. I have to admit, yesterday I was building something and I was so pleased to see the user-defined names in place of gigantic structure definitions. :) |
Considering this fixed for now. |
…defn Fix gap in the text defining the Drop-Check rule.
Fix sparc64-unknown-linux-gnu tests Run sparc64 test in qemu system like s390x. Fix O_TMPFILE const. Fixes rust-lang/libc#822
* Loose type analysis for float add
* Change expected files and add flags to explicitly demand old output * Fix issues with dry run and change default output to regular style * Add UI test suite
Since we got rid of cnames (for good reason, as I understand it), typechecker error messages always use the full structural types, which is sucky. Patrick says he has a plan for fixing this that isn't high priority right now. Creating this bug to track.
We probably want this fixed for a release?
The text was updated successfully, but these errors were encountered: