summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn J. Camilleri <john@digitalgrammars.com>2019-06-10 09:48:44 +0200
committerJohn J. Camilleri <john@digitalgrammars.com>2019-06-10 09:48:44 +0200
commitbbd1c9147a0a58c45919f5afef0c095ab1fed42d (patch)
treeb5c5882e328d7a186ee0b9ad069391ad0ba0b255
parent4793d376d97b6b6157c88e2586fdbf8d8decbf77 (diff)
Catch for when rules are undefined
-rw-r--r--src/runtime/typescript/gflib.ts13
1 files changed, 7 insertions, 6 deletions
diff --git a/src/runtime/typescript/gflib.ts b/src/runtime/typescript/gflib.ts
index 87c17a839..e3b09ffa7 100644
--- a/src/runtime/typescript/gflib.ts
+++ b/src/runtime/typescript/gflib.ts
@@ -1115,8 +1115,9 @@ class ParseState {
} else {
let trees: Fun[] = []
- let rules = forest[fid]
- rules.forEach((rule: Rule): void => {
+ let rules = forest[fid] // could be undefined
+ for (let j in rules) {
+ let rule: Rule = rules[j]
if (rule.id == 'Const') {
trees.push((rule as Const).lit)
} else {
@@ -1149,7 +1150,7 @@ class ParseState {
break
}
}
- })
+ }
return trees
}
@@ -1495,9 +1496,9 @@ class ActiveItem {
/* eslint-disable @typescript-eslint/no-explicit-any */
/* from Remedial JavaScript by Douglas Crockford, http://javascript.crockford.com/remedial.html */
-function isString(a: any): boolean {
- return typeof a == 'string' || a instanceof String
-}
+// function isString(a: any): boolean {
+// return typeof a == 'string' || a instanceof String
+// }
// function isArray(a: any): boolean {
// return a && typeof a == 'object' && a.constructor == Array
// }