Catch for when rules are undefined

This commit is contained in:
John J. Camilleri
2019-06-10 09:48:44 +02:00
parent 4793d376d9
commit bbd1c9147a

View File

@@ -1115,8 +1115,9 @@ class ParseState {
} else { } else {
let trees: Fun[] = [] let trees: Fun[] = []
let rules = forest[fid] let rules = forest[fid] // could be undefined
rules.forEach((rule: Rule): void => { for (let j in rules) {
let rule: Rule = rules[j]
if (rule.id == 'Const') { if (rule.id == 'Const') {
trees.push((rule as Const).lit) trees.push((rule as Const).lit)
} else { } else {
@@ -1149,7 +1150,7 @@ class ParseState {
break break
} }
} }
}) }
return trees return trees
} }
@@ -1495,9 +1496,9 @@ class ActiveItem {
/* eslint-disable @typescript-eslint/no-explicit-any */ /* eslint-disable @typescript-eslint/no-explicit-any */
/* from Remedial JavaScript by Douglas Crockford, http://javascript.crockford.com/remedial.html */ /* from Remedial JavaScript by Douglas Crockford, http://javascript.crockford.com/remedial.html */
function isString(a: any): boolean { // function isString(a: any): boolean {
return typeof a == 'string' || a instanceof String // return typeof a == 'string' || a instanceof String
} // }
// function isArray(a: any): boolean { // function isArray(a: any): boolean {
// return a && typeof a == 'object' && a.constructor == Array // return a && typeof a == 'object' && a.constructor == Array
// } // }