Skip to content

More(!?) Converter, Comparator and ExpressionList ISSUES 😱  #5848

Closed
@Mr-Darth

Description

@Mr-Darth

Skript/Server Version

[21:05:34 INFO]: [Skript] Skript's aliases can be found here: https://github.com/SkriptLang/skript-aliases
[21:05:34 INFO]: [Skript] Skript's documentation can be found here: https://docs.skriptlang.org/
[21:05:34 INFO]: [Skript] Skript's tutorials can be found here: https://docs.skriptlang.org/tutorials
[21:05:34 INFO]: [Skript] Server Version: git-Paper-49 (MC: 1.20.1)
[21:05:34 INFO]: [Skript] Skript Version: 2.7.0-beta3 (skriptlang-github)
[21:05:34 INFO]: [Skript] Installed Skript Addons: None
[21:05:34 INFO]: [Skript] Installed dependencies: None

Bug Description

Remember #5045? Back with more issues 😈

Part 1: A Little Oopsie 🥒

loop 2 and "dog":
    if loop-value is 2:
        broadcast "hello"

Literal lists, so fun! The above code broadcasts nothing, though :(
The newly created expression list has the return type of java.io.Serializable (see #5047). This, however, isn't the issue yet; the actual problem is getting the comparator. There's no default Serializable - Long comparator, so Skript improvises and crafts a kinda working converted comparator... Well, almost... It appears someone has done a little oopsie here 😬 The condition should check against fromObject, not fromType.

It is worth noting that 2 is loop-value does not fix this, since it'll get to the same broken converter.

Part 2: Almost

Let's assume that little oopsie is fixed.
The converted comparator it uses appears to be something like (Number -> Byte) - Long. The issue here is Byte. Let's say someone would loop 256 and "dog"; converting 256 to byte gets us 0, so the following would work:

loop 256 and "dog":
    if loop-value is 0:
        broadcast "hi"  # it broadcasts ?!?

How does it get Number -> Byte?

See this.
Skript goes through the comparators in search of Serializable - Long. It finds Number - Number.
info.secondType.isAssignableFrom(secondType) is true since Number is a superclass of Long.
So now, for this comparator to work, Skript needs to convert Serializable to Number.

See this.
Skript is searching for a Serializable -> Number converter. It goes through converters and sees Number -> Byte which it wants to apply to Serializable.
fromType.isAssignableFrom(unknownInfo.getFrom()) && toType.isAssignableFrom(unknownInfo.getTo())
Serializable is a superclass of Number AND Number is a superclass of Byte. Great, we found our converter!

So the comparator is something like ([from Serializable]Number -> Byte) - Long. Yeesh.

Part 2.5:

loop 9 hours and 2 pm:
    if loop-value is 2 pm:
        broadcast "blob"

Uh, oh! We get a parse time error on this one 😭
Can't compare an object with a time

Again, swapping the objects does not work: Can't compare a time with an object . Thanks, Skript. 🙄

So... literal lists again... return type is YggdrasilSerializable (oof)
This time Skript simply couldn't find (or improvise) a comparator. In the previous case, Skript was 'lucky' enough to have a Number -> Child of Number converter which it could miraculously force into something new, but now... ☹️

Solution?

Obviously, fixing the little mistake I've mentioned is not even close to being a complete solution (but it definitely must be fixed!!!). The other problems will remain.
The easiest solutions I could find are:

Both seem to work fine, but 🤷

Expected Behavior

Skript should compare objects properly.

Steps to Reproduce

on load:
    loop 2 and "dog":
        if loop-value is 2:
            broadcast "hi" 
    loop 9 hours and 2 pm:
        if 2 pm is loop-value:
            broadcast "blob"

Should've broadcasted:

hi
blob

Errors or Screenshots

No response

Other

Currently, #5815 does not solve any of these problems.

As with #5045, a viable workaround for now is the default value expression (e.g. loop-value ? {_hello} is 2) or anything similar.

Agreement

  • I have read the guidelines above and affirm I am following them with this report.

Metadata

Metadata

Labels

bugAn issue that needs to be fixed. Alternatively, a PR fixing an issue.completedThe issue has been fully resolved and the change will be in the next Skript update.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions