Skip to content
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

Closed
brson opened this issue Jan 4, 2012 · 9 comments
Closed

Allow overloaded literals #1425

brson opened this issue Jan 4, 2012 · 9 comments
Labels
A-type-system Area: Type system
Milestone

Comments

@brson
Copy link
Contributor

brson commented Jan 4, 2012

let i: uint = 0 is not valid and this frustrates almost everybody. Maybe there's some compromise that solves the biggest problem.

@marijnh
Copy link
Contributor

marijnh commented Jan 5, 2012

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 += 1, but not let i = 1), which might confuse people, and B) I think Graydon is allergic to this kind of thing.

@graydon
Copy link
Contributor

graydon commented Feb 15, 2012

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.

@graydon
Copy link
Contributor

graydon commented Mar 22, 2012

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.

@jamorton
Copy link
Contributor

jamorton commented Apr 5, 2012

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:

0x00u16 to 0x0fu16 { }
0x10u16 to 0x20u16 { }
0x21u16 { }
0x22u16 { }

compared to

0x00 to 0x0f { }
0x10 to 0x20 { }
0x21 { }
0x22 { }

I find myself using ints so much less than uints, u8s, etc. The syntax may be logical but its extraordinarily hard to read.

@nikomatsakis
Copy link
Contributor

I have some good ideas for implementing this.

@lkuper
Copy link
Contributor

lkuper commented May 30, 2012

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.

@lkuper
Copy link
Contributor

lkuper commented Jun 1, 2012

I'm getting started on a less hacky solution to this one.

lkuper added a commit that referenced this issue Jun 2, 2012
lkuper added a commit that referenced this issue Jun 15, 2012
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
lkuper added a commit that referenced this issue Jun 15, 2012
@lkuper
Copy link
Contributor

lkuper commented Jun 15, 2012

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...

@lkuper
Copy link
Contributor

lkuper commented Jun 20, 2012

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.

@lkuper lkuper closed this as completed Jun 20, 2012
bjorn3 added a commit to bjorn3/rust that referenced this issue Nov 16, 2023
…line_asm

Implement AES-NI and SHA256 crypto intrinsics using inline asm
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-type-system Area: Type system
Projects
None yet
Development

No branches or pull requests

6 participants