diff --git a/src/Logic/Tags/And.ts b/src/Logic/Tags/And.ts index b1b69b8ab..77ec8e5bb 100644 --- a/src/Logic/Tags/And.ts +++ b/src/Logic/Tags/And.ts @@ -314,6 +314,14 @@ export class And extends TagsFilter { for (let j = i + 1; j < optimized.length; j++) { const ti = optimized[i] const tj = optimized[j] + if ( + !ti || + !tj || + typeof ti.shadows !== "function" || + typeof tj.shadows !== "function" + ) { + continue + } if (ti.shadows(tj)) { // if 'ti' is true, this implies 'tj' is always true as well. // if 'ti' is false, then 'tj' might be true or false @@ -322,6 +330,7 @@ export class And extends TagsFilter { // If 'ti' is true, then 'tj' will be true too and 'tj' can be ignored // If 'ti' is false, then the entire expression will be false and it doesn't matter what 'tj' yields optimized.splice(j, 1) + j-- } else if (tj.shadows(ti)) { optimized.splice(i, 1) i--