Skip to content

lexer returns SyntaxError for i64::MIN literal #351

Answered by mitsuhiko
hnakamur asked this question in Q&A
Discussion options

You must be logged in to vote

I wanted to fix up some of those edge cases for a while but I was too lazy. The correct thing to do would be for the lexer to have to tokens: a u64 for integers and a u128 for large integers. Then neg (which is currently invoked for all negative integers) gets a special case for 170141183460469231731687303715884105728 which is the largest possible positive integer that can still be negated. Independently of that, it's a bit ridiculous that the compiler emits opcodes for negations of numbers to begin with. It should really compile -42 into just a constant rather than Neg + LoadConst.

I will fix this.

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@mitsuhiko
Comment options

@hnakamur
Comment options

Answer selected by hnakamur
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants