(
id: Node & { name: string },
fn: Node,
module: SourceModule,
seen: Set<Node>
)
| 201 | } |
| 202 | |
| 203 | private isSameRead( |
| 204 | id: Node & { name: string }, |
| 205 | fn: Node, |
| 206 | module: SourceModule, |
| 207 | seen: Set<Node> |
| 208 | ): boolean { |
| 209 | const reference = module.scopes.byId.get(id) |
| 210 | // e.g. a member's or key's name |
| 211 | if (!reference) return true |
| 212 | const { binding } = reference |
| 213 | if (!binding) return id.name !== "eval" |
| 214 | const isSelf = binding.kind === "function" && binding.declaration === fn |
| 215 | if (!isSelf && contains(fn, binding.id)) return true |
| 216 | const located = this.locate(binding, module) |
| 217 | if (located === "arktype") return true |
| 218 | if (!located) return false |
| 219 | const [origin, declaring] = located |
| 220 | const source = |
| 221 | origin.kind === "function" ? |
| 222 | !origin.writes.length && origin.declaration |
| 223 | : origin.kind === "const" && initOf(origin) |
| 224 | if (!source) return false |
| 225 | // a read passing a function on could write what's on it, and nothing |
| 226 | // keeps a run's from another's where one compares them |
| 227 | if (isFunctionNode(source)) { |
| 228 | const [callee, parent] = operatorOf(id) |
| 229 | return ( |
| 230 | parent?.type === "CallExpression" && |
| 231 | parent.callee === callee && |
| 232 | this.reads(source, declaring, seen) |
| 233 | ) |
| 234 | } |
| 235 | return ( |
| 236 | this.fixedDepthOfBinding(origin, declaring, new Set()) !== undefined || |
| 237 | this.isSameType(origin, declaring, seen) |
| 238 | ) |
| 239 | } |
| 240 | |
| 241 | // a Type is immutable, so it differs only by the functions it holds |
| 242 | private isSameType( |
no test coverage detected