However, we need to be careful not to introduce ambiguity into the grammar, so likely we will only have a negate operator (and not negative literals). Then, as an AST transformation, we should fold a unary negate + literal into just a negative literal. This is a little tricky still, since ideally we do bounds-checking after we perform the fold. That would be before during type analysis though, so this is not a huge issue.
One test should be to construct the largest and smallest i64 values.
Type checking must be smart enough to know that unsigned integers cannot be negated.
In principle, this is easy.
However, we need to be careful not to introduce ambiguity into the grammar, so likely we will only have a negate operator (and not negative literals). Then, as an AST transformation, we should fold a unary negate + literal into just a negative literal. This is a little tricky still, since ideally we do bounds-checking after we perform the fold. That would be before during type analysis though, so this is not a huge issue.
One test should be to construct the largest and smallest i64 values.
Type checking must be smart enough to know that unsigned integers cannot be negated.