Skip to content

Fix Syntax Removal #7879

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: dev/patch
Choose a base branch
from

Conversation

APickledWalrus
Copy link
Member

Problem

Unregistering syntax via SyntaxRegistry#unregister will often fail silently. The issue was caused by the comparator used in SyntaxRegister not enforcing a consistent order for unique SyntaxInfos. Currently, elements are ordered first by Priority. Within the group of elements that share a Priority, it is ordered by registration-order (that is, which one was registered first). This ordering is random and not derived from any properties of the SyntaxInfos themselves. Thus, if I register some SyntaxInfo "A" and then register a whole bunch more, there is no guarantee that a call like register.contains(A) will be successful (it may not reach "A" due to the underlying data structure used).

Solution

The issue is resolved by enforcing a consistent ordering. That is, there will always be a consistent ordering for any collection of SyntaxInfos. This means it is no longer safe to simply change registration order to fix conflicts. Of course, this was never safe, and one should instead use Priorities - they are designed for this issue! This consistency accomplished by using hashcodes for ordering SyntaxInfos that share a priority.

Testing Completed

A new JUnit test was introduced in SyntaxRegistryTest.

Supporting Information

n/a


Completes: none
Related: none

This resolves the issue with removals not  working
@APickledWalrus APickledWalrus requested a review from a team as a code owner May 19, 2025 20:00
@APickledWalrus APickledWalrus added the bug An issue that needs to be fixed. Alternatively, a PR fixing an issue. label May 19, 2025
@APickledWalrus APickledWalrus requested review from cheeezburga and erenkarakal and removed request for a team May 19, 2025 20:00
@skriptlang-automation skriptlang-automation bot added the needs reviews A PR that needs additional reviews label May 19, 2025
@APickledWalrus APickledWalrus requested a review from sovdeeth May 19, 2025 20:01
@APickledWalrus APickledWalrus marked this pull request as draft May 19, 2025 20:41
@skriptlang-automation skriptlang-automation bot removed the needs reviews A PR that needs additional reviews label May 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug An issue that needs to be fixed. Alternatively, a PR fixing an issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant