From 9b485924d6d1ebb7152ace0e7daff03f6bc92674 Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Mon, 26 Feb 2024 15:33:26 -0800 Subject: [PATCH] Fix invalid parse stack recursive merging with mismatched error cost Allowing this invalid merge caused an invariant to be violated later on during parsing, when handling a later error. Co-authored-by: Amaan Qureshi Co-authored-by: Marshall --- lib/src/stack.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/src/stack.c b/lib/src/stack.c index e0d9ea98..98d8c561 100644 --- a/lib/src/stack.c +++ b/lib/src/stack.c @@ -228,7 +228,8 @@ static void stack_node_add_link( // If the previous nodes are mergeable, merge them recursively. if ( existing_link->node->state == link.node->state && - existing_link->node->position.bytes == link.node->position.bytes + existing_link->node->position.bytes == link.node->position.bytes && + existing_link->node->error_cost == link.node->error_cost ) { for (int j = 0; j < link.node->link_count; j++) { stack_node_add_link(existing_link->node, link.node->links[j], subtree_pool);