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

Method mayWriteThrough

ark/aot/graph.ts:5674–5691  ·  view source on GitHub ↗
(
		pattern: Node,
		held: Held,
		module: SourceModule
	)

Source from the content-addressed store, hash-verified

5672
5673 // e.g. `const { a } = o`, through whose bindings the program may write `o`
5674 private mayWriteThrough(
5675 pattern: Node,
5676 held: Held,
5677 module: SourceModule
5678 ): Node | undefined {
5679 const holdings = patternHoldingsOf(pattern, held)
5680 if (!holdings) return this.escape(pattern)
5681 for (const [id, held] of holdings) {
5682 const binding = module.scopes.bindingsById.get(id)
5683 if (!binding || held.depth <= held.copied) continue
5684 // the program's imports of a package's modules aren't linked
5685 if (binding.exportNames.length && this.isPackageModule(module))
5686 return this.escape(id)
5687 this.holdings?.push({ binding, module, held })
5688 const [write] = this.mayWritesOf(binding, module, held)
5689 if (write) return write
5690 }
5691 }
5692
5693 // e.g. `list.forEach(v => { v.a = 1 })`, passing what a receiver holds to a
5694 // callback, which is unknown unless the build reads it: each parameter

Callers 2

mayWriteInCallbackMethod · 0.95
mayWriteFromMethod · 0.95

Calls 6

escapeMethod · 0.95
isPackageModuleMethod · 0.95
mayWritesOfMethod · 0.95
patternHoldingsOfFunction · 0.85
getMethod · 0.65
pushMethod · 0.45

Tested by

no test coverage detected