-
Notifications
You must be signed in to change notification settings - Fork 13k
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
Allow overloaded literals #1425
Comments
This would actually be pretty easy to do, but A) it'll only work in contexts where the type of the literal is known before the typechecker reaches the literal (so the above would work, as would |
I don't know the typechecker well enough to say how invasive this is, and/or how determinstic this can be made. I would want it to be very predictable. |
Email summary of IRC discussion: https://mail.mozilla.org/pipermail/rust-dev/2012-March/001461.html Any other preferences? I believe niko is working on refactoring typeck presently. |
I would really really really like this to be implemented. I'm creating an emulator and I cast my u16's to ints before alting them because I can't read the pattern matching when it looks like:
compared to
I find myself using ints so much less than uints, u8s, etc. The syntax may be logical but its extraordinarily hard to read. |
I have some good ideas for implementing this. |
The pull request I just put in (#2469) is a stab at making it possible to drop the "u" suffix under certain conditions. From talking to @nikomatsakis, it sounds like a more principled approach would have to involve creating a new kind of type variable and doing unification on those, separately from the existing type vars; this is more of a quick hack. |
I'm getting started on a less hacky solution to this one. |
In this commit: * Change the lit_int_unsuffixed AST node to not carry a type, since it doesn't need one * Don't print "(unsuffixed)" when pretty-printing unsuffixed integer literals * Just print "I" instead of "(integral)" for integral type variables * Set up trans to use the information that will be gathered during typeck to construct the appropriate constants for unsuffixed int literals * Add logic for handling int_ty_sets in typeck::infer * Clean up unnecessary code in typeck::infer * Add missing mk_ functions to middle::ty * Add ty_var_integral to a few of the type utility functions it was missing from in middle::ty
Sorry for all the commit spam on this issue. I'm getting close to having something that works well. e3f73e4 has some examples of tests that I have passing locally. I'm hoping to be able to un-xfail these and enable suffix inference in the compiler soon... |
As of 3cf582b, suffix inference has landed and seems to be working well enough to close this bug. (Yay!) Please open new bugs for specific issues you encounter with it. |
…line_asm Implement AES-NI and SHA256 crypto intrinsics using inline asm
let i: uint = 0
is not valid and this frustrates almost everybody. Maybe there's some compromise that solves the biggest problem.The text was updated successfully, but these errors were encountered: