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

Fix drop_back call in scope_stack #4099

Merged
merged 1 commit into from
Jul 3, 2024

Conversation

jonmeow
Copy link
Contributor

@jonmeow jonmeow commented Jul 2, 2024

I found this through inspection, looking at an array stack data type. Tests pass either way, not sure what a good test would be for regressions (tests do fail if the size doesn't match, but either approach gets an appropriate size). But this is followed by truncate(remaining_compile_time_bindings), so it seems like drop_back is a better match than drop_front.

Copy link
Contributor

@zygoloid zygoloid left a comment

Choose a reason for hiding this comment

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

I spent a while trying to build a testcase for this, but I think currently it's unobservable: the only way we can observe the list of compile-time bindings is to look at how they get associated with newly-declared Generics, and so to see a difference, we'd need to introduce a generic in a scope that we suspended and then resumed. And that means we'd need to declare a generic in a function body.

We don't currently support declaring classes, interfaces, or functions within a function body (the parser rejects), so there's no way to observe the bug that this PR fixes.

=> Approving without a test.

@zygoloid zygoloid added this pull request to the merge queue Jul 3, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Jul 3, 2024
@zygoloid zygoloid added this pull request to the merge queue Jul 3, 2024
Merged via the queue into carbon-language:trunk with commit f5f8342 Jul 3, 2024
9 checks passed
@jonmeow jonmeow deleted the drop-front branch July 3, 2024 15:38
github-merge-queue bot pushed a commit that referenced this pull request Jul 3, 2024
Based on discussion around the region handling in generic_region_stack,
create a generic structure for the stack-of-vectors support. I also want
to add this to InstBlockStack, but that's a little more complex due to
GlobalInit, so cutting a PR here to check with review.

My work here is how I noticed #4099; I want to be sure that I'm correct
about the issue, but it's the difference between being able to use
PeekArray or not.

Note in scope_stack.h, I believe we could remove next_compile_time_index
and make it just based on elements_size(). However, I want to verify
with you before I make further changes there.

---------

Co-authored-by: Chandler Carruth <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants