From 9140cbc29e29298f4ba21b0b0a098c512433f864 Mon Sep 17 00:00:00 2001 From: kpreisser Date: Sat, 5 Jan 2019 11:45:46 +0100 Subject: [PATCH] Correctly adjust the backward reference of the next entry when deleting an entry. --- src/compiler/core.ts | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/src/compiler/core.ts b/src/compiler/core.ts index 0daf80a53c9..3f5d3207cdd 100644 --- a/src/compiler/core.ts +++ b/src/compiler/core.ts @@ -223,22 +223,25 @@ namespace ts { const entry = this.data[key]; delete this.data[key]; - // Adjust the linked list references. - const previousElement = entry.previousEntry!; - previousElement.nextEntry = entry.nextEntry; + // Adjust the linked list references of the neighbor entries. + const previousEntry = entry.previousEntry!; + previousEntry.nextEntry = entry.nextEntry; + if (entry.nextEntry) { + entry.nextEntry.previousEntry = previousEntry; + } + + // When the deleted entry was the last one, we need to + // adust the endElement reference. + if (this.linkedListEnd === entry) { + this.linkedListEnd = previousEntry; + } // Adjust the forward reference of the deleted element // in case an iterator still references it. entry.previousEntry = undefined; - entry.nextEntry = previousElement; + entry.nextEntry = previousEntry; entry.skipNext = true; - // When the deleted entry was the last one, we need to - // adust the endElement reference - if (this.linkedListEnd === entry) { - this.linkedListEnd = previousElement; - } - return true; } return false;