From ca902065cb77c16c9734478fc4d823202a11ef25 Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Fri, 24 Jun 2022 13:19:58 -0700 Subject: [PATCH] Fix bug when stack versions merge after reducing a non-terminal extra --- lib/src/parser.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lib/src/parser.c b/lib/src/parser.c index 6fad1664..5959ba01 100644 --- a/lib/src/parser.c +++ b/lib/src/parser.c @@ -1539,6 +1539,13 @@ static bool ts_parser__advance( continue; } + // A non-terminal extra rule was reduced and merged into an existing + // stack version. This version can be discarded. + if (!lookahead.ptr) { + ts_stack_halt(self->stack, version); + return true; + } + // If there were no parse actions for the current lookahead token, then // it is not valid in this state. If the current lookahead token is a // keyword, then switch to treating it as the normal word token if that