Repository navigation
Refuse norm(v) and beta(x) with one argument, read as products with no error - #2499
Merged
Merged
Conversation
…o error A one-argument call of norm or beta was read as the product of a variable named for it with its argument: norm([3, 4]) simplified to [3 * norm, 4 * norm], where the length is 5, and beta(x) was beta * x. Each now throws FunctionArgumentCountException naming what to write: norm(v, 2) for the length, which is abs(v), and beta(a, b), or norm * (...) and beta * (...) for the product. The name alone is a variable and with a space before the bracket a product, as the other names refused by name are. Refused before the grammar, so the grammar is unchanged. The MCP server's IsFunction now says yes for both, a one-argument call no longer being a product; kappa takes beta's place in its test, and in the library's test of a short name read as a product. Syntax.md says both are refused. Full check: 21112 of 21125 unit tests pass, 13 skipped; MCP 459 of 459; harnesses clean and the three baselines matched. MathS.Parse throwing for these, as it already does for factorize(360), is #2498. Part of #2182 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 #2499 +/- ##
=======================================
Coverage 86.90% 86.90%
=======================================
Files 336 336
Lines 73587 73587
Branches 21419 21419
=======================================
Hits 63951 63951
Misses 5188 5188
Partials 4448 4448
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.
Part of #2182.
A call of
normorbetawith one argument was read as the product of a variable named for it with its argument, with no error. #2486 kept that reading and left what a one-argument form should mean to #1019. Rafael has now decided to refuse it, the way 2.8.0 refusedfactorize(…)and the other names in #2453.Measured, master against this branch:
norm([3, 4])norm * [3, 4], and[3 * norm, 4 * norm]once simplifiedFunctionArgumentCountException: the length isnorm(v, 2), which isabs(v)beta(x)beta * xFunctionArgumentCountException:beta(a, b)takes two argumentsnorm(x)^2,2^beta(x),norm({1, 2})norm,norm (x),beta (x)norm([3, 4], 2),beta(2, 3)5,1/12Each message also says to write
norm * (…)orbeta * (…)where the product was meant.The refusal is made in
Parser.cs, in place of the step that handed a one-argument call back as a name and a bracket, so the grammar is unchanged.The tests that pinned the old reading now assert the refusal and its message. The MCP server's
IsFunctionnow says yes for both names, andkappareplacesbetain its test and in the library's test of a short name read as a product.Syntax.mddescribes the refusal in both of its paragraphs, andBREAKING-CHANGES.mdhas a not-silent entry underUnreleased — since 2.8.0.Full check: 21,112 of 21,125 unit tests pass (13 skipped). MCP passes 459 of 459, with Terminal, Interactive, F# and the AOT smoke test. All harnesses are clean, and the three baselines match.
Not in this PR:
MathS.Parsethrows for these refusals as it already does on master forfactorize(360)andnorm(v, p, q), though it is meant not to throw (#2498). So the MCP server reports such an input as a tool that threw, not as a failed parse. That gets its own fix and MCP tests.🤖 Generated with Claude Code