Skip to content

Commit

Permalink
Fix invalid parse stack recursive merging with mismatched error cost
Browse files Browse the repository at this point in the history
Allowing this invalid merge caused an invariant to be violated
later on during parsing, when handling a later error.

Co-authored-by: Amaan Qureshi <amaanq12@gmail.com>
Co-authored-by: Marshall <marshall@zed.dev>
  • Loading branch information
3 people committed Feb 27, 2024
1 parent eb35502 commit 9b48592
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/src/stack.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 9b48592

Please sign in to comment.