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

Merged

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
@APickledWalrus
Copy link
Member Author

On hold as this results in a lot of syntax conflicts that we can't reasonably resolve. Ideally, pull requests like #7892 should help with this.

@sovdeeth sovdeeth removed their request for review June 29, 2025 22:48
@APickledWalrus APickledWalrus added the breaking changes Pull or feature requests that contain breaking changes (API, syntax, etc.) label Jul 1, 2025
@APickledWalrus
Copy link
Member Author

Breaking changes:

  • Syntax ordering is no longer based on registration order
  • EffLoadWorld now requires world in the load effect. load %strings% was not ideal.

@APickledWalrus APickledWalrus marked this pull request as ready for review July 1, 2025 16:24
@APickledWalrus APickledWalrus requested a review from a team as a code owner July 1, 2025 16:24
@APickledWalrus APickledWalrus requested review from UnderscoreTud and removed request for a team July 1, 2025 16:25
@skriptlang-automation skriptlang-automation bot added the needs reviews A PR that needs additional reviews label Jul 1, 2025
@skriptlang-automation skriptlang-automation bot added patch-ready A PR/issue that has been approved and is ready to be merged/closed for the next patch version. and removed needs reviews A PR that needs additional reviews labels Jul 1, 2025
@github-project-automation github-project-automation bot moved this from In Review to Awaiting Merge in 2.12 Release Jul 1, 2025
@APickledWalrus APickledWalrus merged commit 145882c into SkriptLang:dev/patch Jul 1, 2025
5 checks passed
@APickledWalrus APickledWalrus deleted the patch/syntax-removal branch July 1, 2025 21:40
@skriptlang-automation skriptlang-automation bot added the completed The issue has been fully resolved and the change will be in the next Skript update. label Jul 1, 2025
@github-project-automation github-project-automation bot moved this from Awaiting Merge to Done in 2.12 Release Jul 1, 2025
@skriptlang-automation skriptlang-automation bot removed the patch-ready A PR/issue that has been approved and is ready to be merged/closed for the next patch version. label Jul 1, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking changes Pull or feature requests that contain breaking changes (API, syntax, etc.) bug An issue that needs to be fixed. Alternatively, a PR fixing an issue. completed The issue has been fully resolved and the change will be in the next Skript update.
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

4 participants