diff --git a/spec/fixtures/error_corpus/c_errors.txt b/spec/fixtures/error_corpus/c_errors.txt index 05bc7ec2..4dfb0894 100644 --- a/spec/fixtures/error_corpus/c_errors.txt +++ b/spec/fixtures/error_corpus/c_errors.txt @@ -127,5 +127,6 @@ int b() { (ERROR (identifier) (identifier)) (identifier) (number_literal))) (declaration + (ERROR (identifier) (identifier)) (identifier) - (init_declarator (ERROR (identifier) (identifier)) (identifier) (number_literal)))))) + (init_declarator (identifier) (number_literal)))))) diff --git a/src/runtime/parser.c b/src/runtime/parser.c index 3323f19d..d2ea8747 100644 --- a/src/runtime/parser.c +++ b/src/runtime/parser.c @@ -550,7 +550,7 @@ static StackPopResult parser__reduce(Parser *self, StackVersion version, // If this pop operation terminated at the end of an error region, then // create two stack versions: one in which the parent node is interpreted // normally, and one in which the parent node is skipped. - if (state == ERROR_STATE && allow_skipping) { + if (state == ERROR_STATE && allow_skipping && child_count > 1) { StackVersion other_version = ts_stack_copy_version(self->stack, slice.version); ts_stack_push(self->stack, other_version, parent, false, ERROR_STATE);