MCPcopy Create free account
hub / github.com/arktypeio/arktype / readResult

Method readResult

ark/aot/usage.ts:459–482  ·  view source on GitHub ↗
(call: Node, runtime: RuntimeModule)

Source from the content-addressed store, hash-verified

457
458 // a call's result, which holds errors unless it's past a test for them
459 private readResult(call: Node, runtime: RuntimeModule): void {
460 const [result, parent] = operatorOf(call)
461 if (parent?.type === "ExpressionStatement") return
462 if (
463 parent?.type !== "VariableDeclarator" ||
464 parent.init !== result ||
465 parent.id.type !== "Identifier"
466 )
467 return this.readErrors(result, parent)
468 const binding = runtime.module.scopes.bindingsById.get(parent.id)!
469 if (
470 binding.kind !== "const" ||
471 binding.exportNames.length ||
472 runtime.passed.includes(binding)
473 ) {
474 this.used.add("errors")
475 return
476 }
477 for (const { id } of binding.references) {
478 if (isDead(id, runtime) || this.isPastErrorsTest(id, binding)) continue
479 const [operand, operator] = operatorOf(id)
480 this.readErrors(operand, operator)
481 }
482 }
483
484 private readErrors(node: Node, parent: Node | null | undefined): void {
485 if (this.isErrorsTest(parent, node)) return

Callers 1

readMethod · 0.95

Calls 6

readErrorsMethod · 0.95
isPastErrorsTestMethod · 0.95
operatorOfFunction · 0.90
isDeadFunction · 0.85
getMethod · 0.65
addMethod · 0.45

Tested by

no test coverage detected