Skip to content

Fix crashes on array comparison - #7451

Closed
RungeCC wants to merge 5 commits into
typst:mainfrom
RungeCC:fix-array-sort-crashing
Closed

RungeCC wants to merge 5 commits into
typst:mainfrom
RungeCC:fix-array-sort-crashing

Conversation

@RungeCC

@RungeCC RungeCC commented Nov 24, 2025 •

Copy link
Copy Markdown
Contributor

Close #6285.

This is done by move the None branch of match by into closure are_in_order.

  • The error message change in case #(1pt, 2pt, 3em).sorted() may relate to some internal differences between stdsort and glidesort; maybe for some specific error types, we should match their output with regular expressions (instead of a simple comparison), but this is beyond the scope of this PR.
  • The added test is pretty verbose, but because it's related to the internal implementation of stdsort, I'm not sure if it's possible to simplify. Now use reproducer from Typst panic on comparison function #6285 (comment).
  • As my comment Typst panic on comparison function #6285 (comment) says, this PR focuses on solving the crash, more fine-grained diagnostics when encountering non-total-order comparison function may be considered in the future.

@RungeCC RungeCC changed the title Fix typst crashes on array comparasion Fix crashes on array comparasion Nov 24, 2025
@laurmaedje laurmaedje added waiting-on-review This PR is waiting to be reviewed. fix A bug fix. labels Nov 25, 2025
@laurmaedje laurmaedje changed the title Fix crashes on array comparasion Fix crashes on array comparison Dec 3, 2025
@laurmaedje

Copy link
Copy Markdown
Member

Closing in favor of #7520. The approach there is simpler and should be safer to backport (less chance for regressions). It's probably also more performant since it avoids an unnecessary extra allocation for retaining the indices which aren't needed. The change in error message is also avoided, though that wouldn't have been a problem.

Thanks for the PR nonetheless!

@laurmaedje laurmaedje closed this Dec 3, 2025
@RungeCC
RungeCC deleted the fix-array-sort-crashing branch December 4, 2025 00:20
@laurmaedje laurmaedje removed the waiting-on-review This PR is waiting to be reviewed. label Dec 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fix A bug fix.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Typst panic on comparison function

2 participants