fix: parse scientific notation in pcb coordinate strings#2331
Open
asapsav wants to merge 4 commits into
Open
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
imrishabh18
requested changes
May 24, 2026
Member
imrishabh18
left a comment
There was a problem hiding this comment.
I am not sure if this is the right place for the fix, can you create a test in here to demonstrate the fix
Author
|
added tests back to reproduce error with and without the fix: @imrishabh18 where is the right place to fix? new to the repo |
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.
Summary
Footprint primitives with CAD-imported coordinates in scientific notation (e.g.
pcbX="-1.1368683772161603e-13mm") were failing with:This happens when footprints are auto-imported from EasyEDA/JLC/KiCad sources that serialize near-zero values as IEEE float dust.
Root cause: In
evaluateCalcString.ts,tokenize()only consumed digits and.for numbers. For1.1368683772161603e-13mmit parsed1.1368683772161603, stopped ate, and treatedeas a unit suffix →Unknown unit: "e", which upstream is reported as an invalid calc expression.Changes
tokenize()to accept optional scientific notation (e/E, optional sign, exponent digits) before the optional unit suffix (mm, etc.)-0to0in the final result (avoids negative zero from unary-on dust values)Testing
Unit tests (
evaluateCalcString):1.5e-2mm→0.0152E+3mm→2000calc(1e-13mm + 2mm)→2Integration test (
<smtpad>):pcbX="-1.1368683772161603e-13mm"andpcbY="0mm"renders withoutsource_invalid_component_property_error; padxis ~0Regression checks:
calc(board.minX + 1mm), legacyboard.minx, etc.)to reproduce error with and without the fix:
git checkout 3477027 -- lib/utils/evaluateCalcString.ts
bun test tests/utils/evaluate-calc-string.test.ts tests/components/primitive-components/smtpad-scientific-notation-coordinates.test.tsx
git checkout HEAD -- lib/utils/evaluateCalcString.ts # restore fix