Skip to content

Conversation

@onbjerg
Copy link
Contributor

@onbjerg onbjerg commented Oct 7, 2025

Handles implicit integer resizing (larger → smaller) for uintN and intN, as well as integer literal conversions. This is plagued by #560 however.

@onbjerg onbjerg self-assigned this Oct 7, 2025
@onbjerg onbjerg requested a review from DaniPopes as a code owner October 7, 2025 16:20
@onbjerg onbjerg added the A-sema Area: semantic analysis label Oct 7, 2025
// handles integer literals
if self.is_integer()
&& other.is_integer()
&& (!self.is_signed() || other.is_signed())
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

?

Suggested change
&& (!self.is_signed() || other.is_signed())
&& self.is_signed() == other.is_signed()

Copy link
Contributor Author

@onbjerg onbjerg Oct 7, 2025

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

Copy link
Member

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

Copy link
Contributor Author

@onbjerg onbjerg Oct 7, 2025

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

@onbjerg onbjerg marked this pull request as draft October 8, 2025 14:46
@onbjerg
Copy link
Contributor Author

onbjerg commented Oct 8, 2025

Putting this in draft, I think it would make sense to tackle #560 first as it makes testing all the cases easier

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-sema Area: semantic analysis

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants