Skip to content
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

[codegen] Better handling of computed lengths #1251

Merged
merged 1 commit into from
Nov 19, 2024
Merged

[codegen] Better handling of computed lengths #1251

merged 1 commit into from
Nov 19, 2024

Conversation

cmyr
Copy link
Member

@cmyr cmyr commented Nov 19, 2024

This fixes an issue where we were incorrectly truncating all computed lengths to u16, even if the resulting value is storedwould be stored as a u32.

We now keep computed values as usize and then generate a conversion for the appropriate type only at the callsite, instead of blindly converting to a u16 earlier on.

(this issue was pointed out in #1244 (comment); thanks @Hoolean!)

This fixes an issue where we were incorrectly truncating the all
computed lengths to be u16s, even if the value would be stored as a u32.

We now keep computed values as usize and then generate a conversion for
the appropriate type only at the callsite, instead of blindly converting
to a u16 earlier on.
Copy link
Member

@dfrg dfrg left a comment

Choose a reason for hiding this comment

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

LGTM. It’s amusing that we haven’t seemed to trigger this with crater.

@cmyr
Copy link
Member Author

cmyr commented Nov 19, 2024

even when permitted I still don't think it's very common to have an array with > 65536 items...

@cmyr cmyr merged commit e717405 into main Nov 19, 2024
10 checks passed
@cmyr cmyr deleted the array-len-fix branch November 19, 2024 17:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants