On Mon, Mar 19, 2012 at 6:33 PM, Chris Peterson <[email protected]> wrote:
> Rust's type checking of ints and uints seems unnecessarily strict. The
> following examples produce compilation errors, but their intent seems
> perfectly safe within the range of the types:
>
>    let a:u8 = 1;   // error even though 1i fits in u8
>    let b:u16 = a;  // error even though u8 fits in u16
>    let c:i32 = b;  // error even though u16 fits in i32
>    let d:int = c;  // error even though i32 fits in int (assuming int is 32
> or 64 bits)
>    let e:i64 = d;  // no error because int is i64 (on my machine)
>

IIRC, we agreed that we will allow overloaded integer literals,
although that might or might not address line 1 in your code, since we
only talked about overloading literals to allow them to be int or
uint. (See https://github.com/mozilla/rust/issues/1425 )

I don't think we have any plans to add implicit casts as implied by
your other 4 examples. It seems too complex -- if any of the variables
in your example were mutated after being initialized, the pass that
would insert these casts would get pretty complicated.

Cheers,
Tim

-- 
Tim Chevalier * http://catamorphism.org/ * Often in error, never in doubt
"There can be no deep disappointment where there is not deep love." --
Martin Luther King, Jr.
_______________________________________________
Rust-dev mailing list
[email protected]
https://mail.mozilla.org/listinfo/rust-dev

Reply via email to