(key: string, value: string, node: BaseNode)
| 501 | } |
| 502 | |
| 503 | keyFails(key: string, value: string, node: BaseNode): string | undefined { |
| 504 | if (this.trav !== "Apply") { |
| 505 | const condition = node.jsCond?.(this, value) |
| 506 | if (condition !== undefined) return `!(${condition})` |
| 507 | if ( |
| 508 | (this.loopDepth > 0 && isRefinedPattern(node)) || |
| 509 | (node.allowsCtx && node.checksCtx) |
| 510 | ) |
| 511 | return |
| 512 | return `!${this.inv(node, { arg: value })}` |
| 513 | } |
| 514 | if (node.hasMorph || node.hasAlias) return |
| 515 | // a value whose predicates read ctx is checked at its key's path |
| 516 | if (node.tfs && node.allowsCtx && node.checksCtx) return |
| 517 | // transforming values are checked by Allows first |
| 518 | const checksAllowsFirst = |
| 519 | node.tfs || |
| 520 | ((this.loopDepth > 0 || (node.is("union") && !node.discriminant)) && |
| 521 | isDecidedByAllows(node)) |
| 522 | const condition = |
| 523 | node.is("union") && !checksAllowsFirst ? |
| 524 | undefined |
| 525 | : node.jsCond?.(this, value) |
| 526 | if (condition !== undefined && !node.is("union")) |
| 527 | return `!(${condition}) && ${this.error(node, key)}` |
| 528 | const allows = |
| 529 | !checksAllowsFirst ? "" |
| 530 | : isRefinedPattern(node) ? |
| 531 | `${this.ref(rejects)}(${this.traversal(node, "Allows")}, ${value}) && ` |
| 532 | : condition === undefined ? `!${this.allows(node, value)} && ` |
| 533 | : `!(${condition}) && ` |
| 534 | // a refined basis Allows rejected failed its basis or its refinement |
| 535 | if (checksAllowsFirst && isRefinedBasis(node)) |
| 536 | return `${allows}${this.failsEither(node.basis!.jsCond(this, value), this.site(node.preStruct[0]), this.site(node.basis!), "data", key)}` |
| 537 | return `${allows}${this.failsIn(`${this.traversal(node, "Apply")}, ${this.data}, ${this.applied(key, value)}`)}` |
| 538 | } |
| 539 | |
| 540 | // a cyclic value is applied inline |
| 541 | private applyKey(key: string, value: string, node: BaseNode): this { |
nothing calls this directly
no test coverage detected