Skip to content

[array_simp] Fix bug in array slice chain simplification #2700

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

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

copybara-service[bot]
Copy link

[array_simp] Fix bug in array slice chain simplification

Rather than just checking if the end index runs off the end of the ultimate base array, we instead check if any intermediate slice can run off the end of the array it's slicing, and truncate the chain if it does.

This avoids complications that can occur when slicing "past the end" of an array, which will pad the array with extra copies of the last entry (to stay consistent with array_index).

Fixes #2692

Rather than just checking if the end index runs off the end of the ultimate base array, we instead check if any intermediate slice can run off the end of the array it's slicing, and truncate the chain if it does.

This avoids complications that can occur when slicing "past the end" of an array, which will pad the array with extra copies of the last entry (to stay consistent with `array_index`).

Fixes #2692

PiperOrigin-RevId: 787263829
@psivaraj
Copy link
Collaborator

Gah, sorry about that. Good catch!

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.

Misoptimization, crasher 1957
2 participants