Fix crash when extras function doesn't return an array.
Fixes #745, which failed due to attempting to call `map` on a non-array. This bails out at the same spot, but with a more illuminating error message.
This commit is contained in:
parent
e24de9d225
commit
683a2da055
1 changed files with 6 additions and 1 deletions
|
|
@ -292,7 +292,12 @@ function grammar(baseGrammar, options) {
|
|||
|
||||
extras = options.extras
|
||||
.call(ruleBuilder, ruleBuilder, baseGrammar.extras)
|
||||
.map(normalize);
|
||||
|
||||
if (!Array.isArray(extras)) {
|
||||
throw new Error("Grammar's 'extras' function must return an array.")
|
||||
}
|
||||
|
||||
extras = extras.map(normalize);
|
||||
}
|
||||
|
||||
let word = baseGrammar.word;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue