-
Notifications
You must be signed in to change notification settings - Fork 66
feat(sema): implicit integer conversions #564
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
base: main
Are you sure you want to change the base?
Conversation
| // handles integer literals | ||
| if self.is_integer() | ||
| && other.is_integer() | ||
| && (!self.is_signed() || other.is_signed()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
?
| && (!self.is_signed() || other.is_signed()) | |
| && self.is_signed() == other.is_signed() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no, an unsigned integer can be assigned to a signed integer and thus the implicit conversion works :)
if lhs is signed, you can assign unsigned or signed
if lhs is unsighed, you can only assign unsigned
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
there should be a difference between literals which can coerce to either signed or unsigned, and typed integers, which can only upcast
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah makes sense but unrelated to ts line
|
Putting this in draft, I think it would make sense to tackle #560 first as it makes testing all the cases easier |
Handles implicit integer resizing (larger → smaller) for
uintNandintN, as well as integer literal conversions. This is plagued by #560 however.