From bbd1c9147a0a58c45919f5afef0c095ab1fed42d Mon Sep 17 00:00:00 2001 From: "John J. Camilleri" Date: Mon, 10 Jun 2019 09:48:44 +0200 Subject: [PATCH] Catch for when rules are undefined --- src/runtime/typescript/gflib.ts | 13 +++++++------ 1 file 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 // }