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

Lexer truncates u64 literals outside u32 range #974

Closed
jandem opened this issue Sep 24, 2011 · 1 comment
Closed

Lexer truncates u64 literals outside u32 range #974

jandem opened this issue Sep 24, 2011 · 1 comment
Labels
A-frontend Area: Compiler frontend (errors, parsing and HIR) E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.

Comments

@jandem
Copy link

jandem commented Sep 24, 2011

Consider this:

use std;

fn main() {
   let x : u64 = 2000000000u64 * 4u64;
   log_err x;

   let y : u64 = 8000000000u64;
   log_err y;
}

The output is:

rt: f462:main:main:                   8000000000
rt: f462:main:main:                   3705032704

It looks like the lexer uses 32-bit integers in scan_number etc.

Noticed this while trying to solve some Project Euler problems using Rust.

@boggle
Copy link
Contributor

boggle commented Nov 16, 2011

The basic analysis is correct but this is more involved, the use of int instead if u/i64 goes up via token::LIT_MACH_INT, ast::lit_mach_int all the way down to tycheck and trans. Will require some work fixing this. Secondary issue would be proper handling of signedness.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-frontend Area: Compiler frontend (errors, parsing and HIR) E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.
Projects
None yet
Development

No branches or pull requests

3 participants