Don't trap on invalid inter-element spacing (e.g. Relation followed by Binary Operator)#67
Open
SuperGooey wants to merge 1 commit into
Open
Conversation
getInterElementSpace() asserted that the spacing type for an adjacent
pair of atoms is never `.invalid`. But some perfectly valid math lists
produce an `.invalid` adjacency in the inter-element spacing table — most
notably a Relation immediately followed by a Binary Operator, as in
`x = -1` (an `=` Relation followed by a `-` Binary Operator).
In debug builds this `assert` traps and crashes the host app on a valid
equation. In release builds the assertion is compiled out and the
function simply falls through to `return 0`, so release and debug already
disagreed on behavior.
Replace the assert with an explicit `if spaceType == .invalid { return 0 }`
so both configurations render such adjacencies with zero inter-element
spacing instead of crashing.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.
Problem
MTTypesetter.getInterElementSpace(_:_:)asserts that the inter-element spacing type for an adjacent atom pair is never.invalid:But some perfectly valid math lists produce an
.invalidadjacency — most commonly a Relation immediately followed by a Binary Operator, e.g.x = -1,a = -b + c,y < -3. In a DEBUG build thisasserttraps and crashes the app on valid equations. In release the assertion is compiled out and the function already falls through toreturn 0, so release behavior is "zero spacing" — only debug crashes.Fix
Handle
.invalidexplicitly by returning0spacing (matching the existing release-build fall-through), instead of asserting:This makes debug and release consistent and stops valid equations from crashing debug builds. No change to spacing for any non-
.invalidadjacency.🤖 Generated with Claude Code