Parser modification to handle UAdd
in front of int constant #215
No reviewers
Labels
No Milestone
No Assignees
2 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: M-Labs/nac3#215
Loading…
Reference in New Issue
No description provided.
Delete Branch "uadd_int_parser_fix"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Currently things like
int64(+9223372036854775807)
(which isi64::MAX
), will break withInteger out of bound
.While this can be explained as:
9223372036854775807
is not directly annotated withint64
so the compiler is handling it as ai32
, I think this might be a bit inconsistent with the cases of the negative signs, whereint64(--9223372036854775807)
does not break, so I attempted to fix this in this PR.If the current behavior is not desirable, this small patch should be able to fix that.
17aa9f1ce8
toe641fa6ebc
force-pushed to rebase on the latest master branch
I don't understand why it does not and also does not produce a silent int32 overflow. Is it because the parser handles both minus signs and puts them into the final value?
Thanks for merging! Yes, the way the current parser does is like a small constant optimization for integer constants, so the two minus signs are handled directly in the parsing phase and will not cause problem in the later type check and codegen phase.