From 5fba369c4abda2db269e39c07a569cc4cea918f6 Mon Sep 17 00:00:00 2001 From: Amaan Qureshi Date: Sun, 16 Jul 2023 23:29:26 -0400 Subject: [PATCH] fix: disallow inlining the first rule This prevents a panic when indexing symbol_ids during the generation process --- cli/src/generate/prepare_grammar/process_inlines.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/cli/src/generate/prepare_grammar/process_inlines.rs b/cli/src/generate/prepare_grammar/process_inlines.rs index 206ef8d3..9452e35a 100644 --- a/cli/src/generate/prepare_grammar/process_inlines.rs +++ b/cli/src/generate/prepare_grammar/process_inlines.rs @@ -203,6 +203,12 @@ pub(super) fn process_inlines( lexical_grammar.variables[symbol.index].name, )) } + SymbolType::NonTerminal if symbol.index == 0 => { + return Err(anyhow!( + "Rule `{}` cannot be inlined because it is the first rule", + grammar.variables[symbol.index].name, + )) + } _ => {} } }