Repository navigation
Conversation
Passing an explicit zero pitch (e.g. lcc_p0mm) made quadTransform skip the falsy-guarded sizing branch (v.p = 0 is falsy), leaving w/h undefined; getQuadCoords then computed NaN pad x/y, which JSON.stringify serializes as null into circuit-json with no error. Throw a clear 'Invalid pitch' error at transform time instead. Covers p, px and py zero values regardless of wrapper-level defaults (lcc sets pl/pw), since a zero pitch stacks all pads regardless of body size.
|
Friendly maintainer review request: this contribution has been updated with the latest fixes and checks. Please review when convenient. Thank you. |
The guard only matched `=== 0`, so a negative pitch survived it. With an explicit body size (`w`/`h`) the falsy `v.p` checks all pass, so the negative pitch silently mirrored/stacked the pad rows and was emitted as valid circuit-json; without a body size it surfaced much later as an unrelated "Each rectangle bound must have min < max on both axes" error. Covered p, px and py. The post-guard pitch derivations stay unguarded on purpose: they are gated on `!v.p`, and every quad family inherits the 0.5mm default for `p`, so once non-positive pitches throw those branches are unreachable.
|
Re-verified against current
The Full suite: Ready to merge at your convenience. A conflict-free rebase onto |
Fixes #871.
Problem
Passing an explicit zero pitch to a quad-family footprint (
lcc_p0mm,qfn16_p0mm, ...) producedNaNpad x/y coordinates — serialized asnullbyJSON.stringify, silently invalidating the circuit-json.Root cause
In
src/fn/quad.ts,quadTransformuses falsy checks (if (!v.w && !v.h && v.p)) to decide whether to derive body size from pitch. Withp=0(explicitly set viap0mm),v.pis falsy → sizing branch skipped →v.w/v.hstay undefined →getQuadCoordscomputesx: -w/2 - pcdfe + 0.1= NaN.Fix
Throw a clear
Invalid pitcherror inquadTransformwhenp,pxorpyis exactly 0. The guard is unconditional (not wrapped in other option checks) because wrapper-level defaults likelcc'spl/pwwould otherwise bypass it — and a zero pitch stacks all pads regardless of body size anyway.Testing
New
tests/quad-zero-pitch.test.ts(3 tests pass):lcc_p0mmandqfn16_p0mmthrow/Invalid pitch.*positive pitch/instead of NaNlcc_px0mmthrows as well