Repository navigation
fix(constraint): read decimal literals in constraint expressions - #10
Merged
Merged
Conversation
Any decimal in a constraint (`totalMass <= 2.5`) failed with "Cannot parse literal value from 'LiteralRational'". SysON's expression results have no real-number type, so `self.value` on a LiteralRational fails in GraphQL; the failure was swallowed and the parser fell back to the element's label. The value is now read with `self.value.toString()`, as the value resolver already does for attributes. Verified on a live SysON: `thrust / (totalMass * 9.81) >= 2`, `totalMass <= 2.5` and `totalMass >= -0.5` now evaluate. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Number('') is 0: a blank or non-finite text for a LiteralRational is now
reported by the parser instead. Tests cover Java's exponent form and the
unreadable texts.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2 tasks done
…l-literals # Conflicts: # CHANGELOG.md
Merged
2 tasks done
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
totalMass <= 2.5orthrust / (totalMass * 9.81) >= 2gaveCannot parse literal value from 'LiteralRational'.self.valueon aLiteralRationaltherefore fails in GraphQL ("non null type … objValue/id"). The error was swallowed, and the parser fell back to the element's label.self.value.toString(), as the attribute value resolver already does. It parses withNumber(notparseFloat: "1/3" is not 1). A blank or non-finite text is reported as an error, never read as 0.syson_constraint_extractbenefits: validation, solving, requirement limits and the requirements trace's authored constraints.Test plan
self.valuethe way SysON does. It failed before the fix with the production error. It now covers2.5and Java's5.5E7.""," ","NaN"and"Infinity"are reported, never read as 0. This test fails without the guard.deno task fmt,lint,check,testthrust / (totalMass * 9.81) >= 2,totalMass <= 2.5andtotalMass >= -0.5all evaluate. Before the fix all three wereerror.Seen, not fixed here
The validation viewer shows the expression
thrust / (totalMass * 9.81)asthrust / totalMass * 9.81; the computed value is right. The cause is in@casys/constraint-solver(format.ts,maybeParen), which never parenthesises a right operand of the same precedence under/or-.🤖 Generated with Claude Code