Repository navigation
MathS.Parse and Entity.TryParse return a refused call rather than throw it - #2500
Merged
Merged
Conversation
…ow it MathS.Parse is the parser that does not throw, and Entity.TryParse the IParsable one that says yes or no. Both threw where the grammar refuses a call: factorize(360) threw UnrecognizedFunctionParseException and norm(v, p, q) FunctionArgumentCountException, since a grammar action that throws has no error recorded against the input. Each is now the failure it describes, Unknown with the refusal's message, and TryParse says false. FromString and the conversion from a string still throw it with its own type. The MCP server's am_parse reported these as a tool that threw, and answers a failed parse now. Full check: 21117 of 21130 unit tests pass, 13 skipped; MCP 461 of 461; harnesses clean and the three baselines matched. Fixes #2498 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #2500 +/- ##
=======================================
Coverage 86.90% 86.90%
=======================================
Files 336 336
Lines 73587 73590 +3
Branches 21419 21419
=======================================
+ Hits 63951 63956 +5
+ Misses 5188 5185 -3
- Partials 4448 4449 +1
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
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 #2498.
MathS.Parseis documented as the parser that does not throw, andEntity.TryParseis theIParsablemethod that answers yes or no. On master, both throw where the grammar refuses a call:MathS.Parse("factorize(360)")UnrecognizedFunctionParseExceptionUnknownwith that messageMathS.Parse("norm(v, p, q)")FunctionArgumentCountExceptionUnknownwith that messageEntity.TryParse("factorize(360)", null, out _)false"factorize(360)".ToEntity()UnrecognizedFunctionParseExceptionam_parseoffactorize(360)tool am_parse threw"status": "failed", with the refusal as the errorA grammar action that throws, such as a refusal by name or an argument-count check, has no error recorded against the input, so
ParseSilentlet the exception through.ParseSilentnow returns aParseExceptionas the failure it describes. The throwing path thatFromStringuses is the same parse with the exception left alone, so callers that catch a particular type are unaffected. OnlyParseExceptionis caught, so a defect still surfaces. Adding a fourth kind of failure would have changed the three-way type union callersSwitchover, so the refusal travels asUnknown, whose documentation now names it.The MCP server's
IsFunctionreads a failure as a call, as it read the exception, so its warnings do not change.This merges cleanly with #2499 in either order (
git merge-tree). Once both are in, a one-argumentnorm(…)given toMathS.Parseis a failure, not an exception.Full check: 21,117 of 21,130 unit tests pass (13 skipped). MCP passes 461 of 461, two tests of them new, with Terminal, Interactive, F# and the AOT smoke test. All harnesses are clean, and the three baselines match.
BREAKING-CHANGES.mdhas a not-silent entry at the top ofUnreleased — since 2.8.0.🤖 Generated with Claude Code