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: avoid popContext on unvisited node paths #16305

Merged
merged 2 commits into from Feb 28, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
@@ -0,0 +1,5 @@
async () => do {
await 0
while (0) {}
0
}
@@ -0,0 +1,5 @@
async () => await async function () {
await 0;
while (0) {}
return 0;
}();
11 changes: 7 additions & 4 deletions packages/babel-traverse/src/context.ts
Expand Up @@ -118,9 +118,12 @@ export default class TraversalContext<S = unknown> {

const visited = new WeakSet();
let stop = false;
let visitIndex = 0;

// visit the queue
for (const path of queue) {
for (; visitIndex < queue.length; ) {
const path = queue[visitIndex];
visitIndex++;
path.resync();

if (
Expand Down Expand Up @@ -154,9 +157,9 @@ export default class TraversalContext<S = unknown> {
}
}

// clear queue
for (const path of queue) {
path.popContext();
// pop contexts
for (let i = 0; i < visitIndex; i++) {
queue[i].popContext();
}

// clear queue
Expand Down