fix: disallow inlining the first rule

This prevents a panic when indexing symbol_ids during the generation process
This commit is contained in:
Amaan Qureshi 2023-07-16 23:29:26 -04:00
parent 1c65ca24bc
commit 5fba369c4a
No known key found for this signature in database
GPG key ID: E67890ADC4227273

View file

@ -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,
))
}
_ => {}
}
}