fix(quad): throw on zero/invalid pitch instead of emitting NaN pad coordinates - #875
Open
billythompsons wants to merge 1 commit into
Open
billythompsons wants to merge 1 commit into
billythompsons wants to merge 1 commit into
Conversation
…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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #871
Problem
Passing an explicit zero pitch to a quad-family footprint (
lcc_p0mm,qfn16_p0mm, etc.) silently producedNaNpad coordinates. InquadTransform, the underspecified-dimension fallbacks gate on truthiness ofv.p, sop = 0skips them:w/hstayundefinedandpw/plfall through toundefined * 0.6 = NaN.getQuadCoordsthen emitsNaNx/y, whichJSON.stringifyturns intonull- silently invalid circuit-json with no error.Fix
Validate the effective pitches (
p,px ?? p,py ?? p) at the end ofquadTransformand throw a descriptive error when any is non-finite or<= 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.tstransforms.Tests
New
tests/quad-zero-pitch.test.ts:lcc_p0mm,qfn16_p0mm,qfn16_px0mmthrow with the new messagelcc,qfn16,qfn16_p0.4mm,lcc_p1mm) still produce finite pad coordinatesFull suite: 566 pass, 0 fail.
biome formatclean.