fix: properly error out when the word property is an invalid rule

This commit is contained in:
Amaan Qureshi 2024-02-10 20:05:29 -05:00
parent cca814afd2
commit 78ccc39ca9
No known key found for this signature in database
GPG key ID: E67890ADC4227273

View file

@ -310,6 +310,10 @@ function grammar(baseGrammar, options) {
if (typeof word != 'string') {
throw new Error("Grammar's 'word' property must be a named rule.");
}
if (word === 'ReferenceError') {
throw new Error("Grammar's 'word' property must be a valid rule name.");
}
}
let conflicts = baseGrammar.conflicts;