Skip to content

Literal Multiple Infos Warning #7851

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

Open
wants to merge 11 commits into
base: dev/feature
Choose a base branch
from

Conversation

Absolutionism
Copy link
Contributor

@Absolutionism Absolutionism commented May 5, 2025

Description

This PR aims to add a warning when a literal, that can be referenced to multiple ClassInfos/types, is used.
The warning informs the user that the literal can be referenced to multiple types and that they should consider specifying which type to use, using the new literal specification feature introduced in 2.11.

This PR also fixes a bug that was present within SkriptParser#parseSingleExpr where when an element's pattern allowed multiple types, including Object for an expression (%.../.../object%) if all other types failed to be parsed and reached Object, it did not treat it correctly as seen with the prior condition check (if (exprInfo.classes[0].getC() == Object.class) {). Which lead to the literal being parsed as the first ClassInfo that gets registered with that pattern. Now the loop will log if it reaches Object and continue to attempt every other ClassInfo. If all fail, and Object was logged, will use the method #getUnparsedLiteral which is the code from the aforementioned condition, to prevent duplicated code.

With that change, a fix was required for CondContains as it did not properly handle UnparsedLiterals.


Target Minecraft Versions: any
Requirements: none
Related Issues: none

@Absolutionism Absolutionism requested review from a team as code owners May 5, 2025 19:05
@Absolutionism Absolutionism requested review from UnderscoreTud and Romitou and removed request for a team May 5, 2025 19:05
@sovdeeth sovdeeth added the enhancement Feature request, an issue about something that could be improved, or a PR improving something. label May 6, 2025
@Absolutionism Absolutionism requested a review from sovdeeth May 9, 2025 18:22
@Absolutionism Absolutionism requested a review from sovdeeth May 12, 2025 03:58
Copy link
Member

@sovdeeth sovdeeth left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

seems pretty solid now

@Absolutionism Absolutionism requested a review from sovdeeth May 13, 2025 22:45
@skriptlang-automation skriptlang-automation bot added the needs reviews A PR that needs additional reviews label May 15, 2025
Copy link
Member

@APickledWalrus APickledWalrus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some initial thoughts. I like the idea

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Feature request, an issue about something that could be improved, or a PR improving something. needs reviews A PR that needs additional reviews
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants