diff --git a/src/runtime/parser.c b/src/runtime/parser.c index 4e5e6c32..979bfdb0 100644 --- a/src/runtime/parser.c +++ b/src/runtime/parser.c @@ -169,7 +169,6 @@ static CondenseResult parser__condense_stack(Parser *self) { continue; } - StackVersion version_to_swap = STACK_VERSION_NONE; ErrorStatus right_error_status = ts_stack_error_status(self->stack, i); if (right_error_status.count == 0) has_version_without_errors = true; @@ -207,8 +206,9 @@ static CondenseResult parser__condense_stack(Parser *self) { result |= CondenseResultMadeChange; i--; j--; - } else if (version_to_swap != STACK_VERSION_NONE) { - version_to_swap = j; + } else { + ts_stack_swap_versions(self->stack, i, j); + j = i; result |= CondenseResultMadeChange; } break; @@ -222,10 +222,6 @@ static CondenseResult parser__condense_stack(Parser *self) { } } } - - if (version_to_swap != STACK_VERSION_NONE) { - ts_stack_swap_versions(self->stack, i, version_to_swap); - } } while (ts_stack_version_count(self->stack) > MAX_VERSION_COUNT) { diff --git a/test/fixtures/error_corpus/javascript_errors.txt b/test/fixtures/error_corpus/javascript_errors.txt index 1cfda563..45eb1c33 100644 --- a/test/fixtures/error_corpus/javascript_errors.txt +++ b/test/fixtures/error_corpus/javascript_errors.txt @@ -15,7 +15,8 @@ e f; (ERROR (identifier)) (identifier)) (statement_block - (expression_statement (ERROR (identifier)) (identifier)))) + (ERROR (identifier)) + (expression_statement (identifier)))) (expression_statement (ERROR (identifier)) (identifier))) =======================================================