[rust-dev] Warn about implicit integer conversion

Niko Matsakis niko at alum.mit.edu
Thu Dec 20 11:17:08 PST 2012


This makes sense.  What I really meant was: Let's not try to do this 
checking during the type check itself, as we initially did, but rather 
as a later lint step.  This also allows you to disable it if you know 
what you're doing and for some reason the code is cleaner as you wrote it.


Niko

Graydon Hoare wrote:
> On 12-12-20 05:59 AM, Niko Matsakis wrote:
>> Lindsey Kuper wrote:
>>> Our thinking at the time we implemented suffix inference was that if
>>> you went so far as to write the optional type annotation, then you
>>> should get the type you asked for, no questions asked, overflows and
>>> all.  After all, sometimes people do want intentional overflow.  But
>>> if it's causing nasty surprises, then, yeah, it should be revisited.
>> I think the best thing would be a simple lint check that visits each
>> literal and checks whether it can fit into the type assigned to it.  It
>> will catch many simple cases like this one.
>
> It is certainly the simplest thing for this case, but I'd also like not
> to paper it over, but to address the bug its general form. The question
> of exactly what constant-folding to do in the front/middle ends, and
> what sorts of conditions during that count as errors, is worth nailing
> down; it will resurface (already has, I've seen several "surprise"
> constant / non-constant behaviors, and heard others stubbing toes on same).
>
> It's already partly-implemented, and I think there's a plan coming into
> focus, just needs more care / thought.
>
> -Graydon
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/rust-dev/attachments/20121220/b6189577/attachment.html>


More information about the Rust-dev mailing list