SkriptLang / skript-reflect

Powerful reflection utilities for Skript.
MIT License
56 stars 19 forks source link

Custom Syntax bug #35

Closed Chsui closed 3 years ago

Chsui commented 3 years ago

Describe the bug There seems to be a problem when using %itemstack% in Custom Syntax. It worked normally in version 2.1.0, but a problem occurred after updating to version 2.2.0.

To reproduce [Normal case-A]

expression test expression %itemstack%:
    get:
        broadcast "%expr-1%"
        return "Done."
on inventory click:
    set {_inv} to player' current inventory
    set {_test} to test expression slot 0 of {_inv}

[Normal case-B]

expression %itemstack% test expression:
    get:
        broadcast "%expr-1%"
        return "Done."
on inventory click:
    set {_test} to slot 0 of player' current inventory test expression

[Bug case]

expression %itemstack% test expression:
    get:
        broadcast "%expr-1%"
        return "Done."
on inventory click:
    set {_inv} to player' current inventory
    set {_test} to slot 0 of {_inv} test expression

Expected behavior In both cases, the item in the 0 slot of the player's inventory is displayed normally. However, in the bug case, is displayed.

Screenshots If applicable, add screenshots to help explain your problem.

Server information

Additional context Add any other context about the problem here.

TPGamesNL commented 3 years ago

It's probably due to Skript parsing the last expression as slot 0 of ({_inv} test expression). It does this, because it doesn't know much about your custom expression. You can set a return type for it (see https://tpgamesnl.gitbook.io/skript-reflect/advanced/custom-syntax/expressions#option-return-type), you should probably set it to string, that should prevent this issue from occuring.

Chsui commented 3 years ago

If so, why didn't that bug exist in version 2.1.0? This bug occurred after the 2.2.0 update.

TPGamesNL commented 3 years ago

Skript is known to be very inconsistent in its parsing, so you should consider which syntax is attempted first to be random.