Repository navigation
Improve errors for incomplete math operators and disallow linebreaks in operands - #7742
Merged
Merged
Conversation
laurmaedje
reviewed
Jan 27, 2026
isuffix
force-pushed
the
math-op-incomplete
branch
from
January 29, 2026 16:32
7eec090 to
707b574
Compare
isuffix
force-pushed
the
math-op-incomplete
branch
2 times, most recently
from
February 10, 2026 00:51
7df8fe1 to
72a3e44
Compare
Collaborator
Author
|
Oof, sorry 😬. We'll need to rebase |
isuffix
force-pushed
the
math-op-incomplete
branch
from
February 10, 2026 00:59
e8068a8 to
f37900b
Compare
Member
|
I updated the |
isuffix
force-pushed
the
math-op-incomplete
branch
from
February 10, 2026 18:40
f37900b to
cef71bf
Compare
Merged
laurmaedje
approved these changes
Feb 19, 2026
isuffix
force-pushed
the
math-op-incomplete
branch
from
February 26, 2026 21:24
cef71bf to
d92f1af
Compare
Member
|
Thank you! |
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 the Math Syntax Refactor
This PR is part of the exhaustive math syntax refactor. It should be considered exploratory, and not necessarily a final decision, even if merged to the
math-syntaxbranch. Non-specific feedback for this change should go in one of its related issues.This PR tightens up our handling of general operators in math (primes will be dealt with separately).
Closes #1435
First commit
In this commit, we now error more predictably when an operator has a missing side, and the error message we give is much better. This resolves the odd behavior of
$(1/)$parsing the close-paren as the fraction's denominator, now giving the error, "expected an expression to the right of the operator".I implemented this by making better use of the
stop_setargument inmath_expr_prec, ensuring that we thread it through recursive operator calls when parsing an operator's right operand, and erroring if we start the call at the stop set.This also improves the error for unclosed delimiters used for grouping. So
$($alone is still fine, but$1/($is an error. This was done by passing in the precedence of the surrounding expression tomath_delimitedand checking that it was higher than zero if we didn't find a closing delimiter.And I removed the
MATH_EXPRsyntax set because theunexpectederror message case was really only used for these operators, and I would prefer to give a more explicit error for them.Second commit
This is simpler and just disallows linebreaks and alignment points as direct operands, requiring parentheses or escaping to place them inside a math operator. Doing so on their own was never actually useful, so this should just improve the editing experience in math.
I did this by adding
LinebreakandMathAlignPointto a newTOP_LEVELsyntax set inmath_exprsthat we handle explicitly at the top-level, but treat as part of the stop set for all calls tomath_expr_prec. This causes us to error whenever an operator would be adjacent to one of these kinds, for the same reason as we error for$/$, but it does not change the behavior if these would just join as part of the top-level math sequence.