From 820446c48e8870094d206ffd68bbfdf81699380b Mon Sep 17 00:00:00 2001 From: Matteo Agius Date: Tue, 6 Aug 2024 15:34:58 +0300 Subject: [PATCH] patch: add nil check for grammer field before g.BlockSyntax call --- parser/parser.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/parser/parser.go b/parser/parser.go index 9211a15..4244c45 100644 --- a/parser/parser.go +++ b/parser/parser.go @@ -57,6 +57,9 @@ func (c Config) parseTokens(tokens []Token) (ASTNode, Error) { // nolint: gocycl case tok.Type == TextTokenType: *ap = append(*ap, &ASTText{Token: tok}) case tok.Type == TagTokenType: + if g == nil { + return nil, Errorf(tok, "Grammer field is nil") + } if cs, ok := g.BlockSyntax(tok.Name); ok { switch { case tok.Name == "comment":