Bun parity exposed two related checker flow defects in Zod 4.5.2:
instanceof Mapandinstanceof Setnarrowedunknownto broadobject, losing their iterable and collection interfaces.- A literal comparison against a broad property such as
array.length === 0incorrectly treated the property as a discriminant and narrowed the receiver toneveron the opposite branch.
Implemented on main in 3886689:
- resolve Map, Set, WeakMap, and WeakSet constructor guards to their structural instance types;
- only discriminate a single object through unit-typed properties;
- add regression coverage for collection guard iteration and array-length fallthrough.
Validation:
- focused iterable checker tests: 27/27 passed;
- complete ReleaseFast checker suite: 4,389/4,389 passed;
- full JSC-enabled ReleaseFast build: 50/50 steps succeeded;
- pinned Zod 4.5.2 diagnostics: 25 -> 21, with four primary removals, one dependent cascade removed, and zero additions.