Skip to content

fix(quad): throw on zero/invalid pitch instead of emitting NaN pad coordinates - #875

Open
billythompsons wants to merge 1 commit into
tscircuit:mainfrom
billythompsons:fix-quad-zero-pitch
Open

billythompsons wants to merge 1 commit into
tscircuit:mainfrom
billythompsons:fix-quad-zero-pitch

Conversation

@billythompsons

Copy link
Copy Markdown

Fixes #871

Problem

Passing an explicit zero pitch to a quad-family footprint (lcc_p0mm, qfn16_p0mm, etc.) silently produced NaN pad coordinates. In quadTransform, the underspecified-dimension fallbacks gate on truthiness of v.p, so p = 0 skips them: w/h stay undefined and pw/pl fall through to undefined * 0.6 = NaN. getQuadCoords then emits NaN x/y, which JSON.stringify turns into null - silently invalid circuit-json with no error.

Fix

Validate the effective pitches (p, px ?? p, py ?? p) at the end of quadTransform and throw a descriptive error when any is non-finite or <= 0:

Invalid p (0) for lcc: pitch must be a number greater than 0

A zero-pitch package has degenerate geometry (all pads on the same line), so a clear thrown error is the right outcome - this matches the error style already used in dfn.ts/lga.ts transforms.

Tests

New tests/quad-zero-pitch.test.ts:

  • lcc_p0mm, qfn16_p0mm, qfn16_px0mm throw with the new message
  • valid quad footprints (lcc, qfn16, qfn16_p0.4mm, lcc_p1mm) still produce finite pad coordinates

Full suite: 566 pass, 0 fail. biome format clean.

…ordinates

An explicit zero pitch (e.g. lcc_p0mm, qfn16_p0mm) skipped the
underspecified-dimension fallbacks because v.p === 0 is falsy, leaving
w/h undefined and pw/pl NaN. getQuadCoords then produced NaN pad x/y,
which JSON.stringify serializes as null - silently invalid circuit-json.

Validate the effective p/px/py at the end of quadTransform and throw a
descriptive error when any is non-finite or <= 0.

Fixes tscircuit#871
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: zero pitch on quad-family footprints produces NaN pad coordinates

1 participant