Skip to content

MathS.Parse and Entity.TryParse return a refused call rather than throw it - #2500

Merged
Rafael-SOWNet merged 1 commit into
masterfrom
parse-returns-a-refusal
Nov 16, 2026
Merged

Rafael-SOWNet merged 1 commit into
masterfrom
parse-returns-a-refusal

Conversation

@Rafael-SOWNet

Copy link
Copy Markdown
Member

Fixes #2498.

MathS.Parse is documented as the parser that does not throw, and Entity.TryParse is the IParsable method that answers yes or no. On master, both throw where the grammar refuses a call:

input master this branch
MathS.Parse("factorize(360)") throws UnrecognizedFunctionParseException a failure, Unknown with that message
MathS.Parse("norm(v, p, q)") throws FunctionArgumentCountException a failure, Unknown with that message
Entity.TryParse("factorize(360)", null, out _) throws false
"factorize(360)".ToEntity() throws UnrecognizedFunctionParseException the same
MCP am_parse of factorize(360) logged as tool am_parse threw "status": "failed", with the refusal as the error

A grammar action that throws, such as a refusal by name or an argument-count check, has no error recorded against the input, so ParseSilent let the exception through. ParseSilent now returns a ParseException as the failure it describes. The throwing path that FromString uses is the same parse with the exception left alone, so callers that catch a particular type are unaffected. Only ParseException is caught, so a defect still surfaces. Adding a fourth kind of failure would have changed the three-way type union callers Switch over, so the refusal travels as Unknown, whose documentation now names it.

The MCP server's IsFunction reads 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-argument norm(…) given to MathS.Parse is 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.md has a not-silent entry at the top of Unreleased — since 2.8.0.

🤖 Generated with Claude Code

…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

codecov Bot commented Nov 16, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 86.90%. Comparing base (dce1653) to head (47d1754).
⚠️ Report is 1 commits behind head on master.

Additional details and impacted files

Impacted file tree graph

@@           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     
Flag Coverage Δ
cpp 37.77% <ø> (ø)
csharp 87.42% <100.00%> (+<0.01%) ⬆️
fsharp 32.79% <ø> (ø)
interactive 40.09% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
Sources/AngouriMath/Core/Parser.cs 82.63% <100.00%> (+0.36%) ⬆️

... and 7 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@Rafael-SOWNet
Rafael-SOWNet merged commit b76751a into master Nov 16, 2026
35 checks passed
@github-project-automation github-project-automation Bot moved this from Todo to Done in AngouriMath Nov 16, 2026
@Rafael-SOWNet
Rafael-SOWNet deleted the parse-returns-a-refusal branch November 16, 2026 18:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

MathS.Parse throws for a refused name or a wrong argument count, though it is the non-throwing parser

1 participant