Skip to content

Commit 9140cbc

Browse files
committed
Correctly adjust the backward reference of the next entry when deleting an entry.
1 parent c4960d3 commit 9140cbc

File tree

1 file changed

+13
-10
lines changed

1 file changed

+13
-10
lines changed

src/compiler/core.ts

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -223,22 +223,25 @@ namespace ts {
223223
const entry = this.data[key];
224224
delete this.data[key];
225225

226-
// Adjust the linked list references.
227-
const previousElement = entry.previousEntry!;
228-
previousElement.nextEntry = entry.nextEntry;
226+
// Adjust the linked list references of the neighbor entries.
227+
const previousEntry = entry.previousEntry!;
228+
previousEntry.nextEntry = entry.nextEntry;
229+
if (entry.nextEntry) {
230+
entry.nextEntry.previousEntry = previousEntry;
231+
}
232+
233+
// When the deleted entry was the last one, we need to
234+
// adust the endElement reference.
235+
if (this.linkedListEnd === entry) {
236+
this.linkedListEnd = previousEntry;
237+
}
229238

230239
// Adjust the forward reference of the deleted element
231240
// in case an iterator still references it.
232241
entry.previousEntry = undefined;
233-
entry.nextEntry = previousElement;
242+
entry.nextEntry = previousEntry;
234243
entry.skipNext = true;
235244

236-
// When the deleted entry was the last one, we need to
237-
// adust the endElement reference
238-
if (this.linkedListEnd === entry) {
239-
this.linkedListEnd = previousElement;
240-
}
241-
242245
return true;
243246
}
244247
return false;

0 commit comments

Comments
 (0)