| 250 | } |
| 251 | |
| 252 | const writesUnread = (places: Map<string, Place>): boolean => { |
| 253 | const readers: [Place, Reads][] = [] |
| 254 | for (const place of places.values()) { |
| 255 | const reads = readsOf(place.node) |
| 256 | if (reads) readers.push([place, reads]) |
| 257 | } |
| 258 | for (const place of places.values()) { |
| 259 | const writer = writerOf(place.node) |
| 260 | if (!writer) continue |
| 261 | // a function can return an object that outlives the call |
| 262 | if (place.afterFunction) return false |
| 263 | const writes = writesOf(writer) |
| 264 | if ( |
| 265 | place.count > 1 && |
| 266 | (!isEmpty(writes.values) || |
| 267 | (!isEmpty(writes.added) && !writes.addsOnlyDefaults)) |
| 268 | ) |
| 269 | return false |
| 270 | for (const [reader, reads] of readers) { |
| 271 | if ( |
| 272 | reader === place || |
| 273 | (reader.count === 1 && |
| 274 | place.count === 1 && |
| 275 | reader.position === place.position) |
| 276 | ) |
| 277 | continue |
| 278 | if ( |
| 279 | (meet(writes.values, reads.values) || |
| 280 | meet(writes.added, reads.values) || |
| 281 | (reads.everyPresence && !isEmpty(writes.added))) && |
| 282 | overlaps(place.node, reader.node) |
| 283 | ) |
| 284 | return false |
| 285 | } |
| 286 | } |
| 287 | return true |
| 288 | } |
| 289 | |
| 290 | /** arktype's morphs passed ctx that read only their input through it */ |
| 291 | export const inputOnlyMorphs: WeakSet<Function> = new WeakSet() |