Skip to content

Functions that do not have a return type throw an exception when used in conjunction with itemstack-related effects in a command structure #8466

@2clist

Description

@2clist

Skript/Server Version

[17:20:37 INFO]: [Skript] Skript's aliases can be found here: https://github.com/SkriptLang/skript-aliases
[17:20:37 INFO]: [Skript] Skript's documentation can be found here: https://docs.skriptlang.org/
[17:20:37 INFO]: [Skript] Skript's tutorials can be found here: https://docs.skriptlang.org/tutorials
[17:20:37 INFO]: [Skript] Server Version: 1.21.11-111-302c47c (MC: 1.21.11)
[17:20:37 INFO]: [Skript] Skript Version: 2.14.1 (skriptlang-github)
[17:20:37 INFO]: [Skript] Installed Skript Addons: 
[17:20:37 INFO]: [Skript]  - skript-yaml v1.7.2
[17:20:37 INFO]: [Skript]  - skript-reflect v2.6.2 (https://github.com/SkriptLang/skript-reflect)
[17:20:37 INFO]: [Skript]  - SkBee v3.17.1 (https://github.com/ShaneBeee/SkBee)
[17:20:37 INFO]: [Skript]  - SkBriggy v1.5.8 (https://github.com/ShaneBeee/SkBriggy)
[17:20:37 INFO]: [Skript] Installed dependencies: 
[17:20:37 INFO]: [Skript]  - Vault v1.7.3-b131
[17:20:37 INFO]: [Skript]  - WorldGuard v7.0.15+2347-5fafea6

Bug Description

Functions that do not have a return type (whether or not they return any value in the function's code is irrelevant) cause an exception when used specifically in a command structure and in itemstack-related effects such as give (%players% %itemtypes%|%itemtypes% to %players%).

Expected Behavior

The function should return a null value that Skript ignores, and the command should be registered as normal.

Steps to Reproduce

Put the following script in a file and reload it:

# Compiles without Skript errors, but errors in console and does not allow the command to be registered.
function foo():
    set {_} to "something"

# Compiles and allows the command to be registered, even though it does not return anything.
function foo2() :: item:
    set {_} to "something"
    
command /bar:
    trigger:
        # Causes the command to not register
        give player foo()
        set slot 0 of player to foo()

        # Command registers just fine.
        send foo()
        teleport player to foo()

# Registers function and is executable via effect commands. Gives the player cobblestone since foo() does not return anything.
function bar(p: player):
  give {_p} (foo() ? cobblestone)

Testing Procedure:

  1. Notice that the /bar command is not registered.
  2. Comment out lines 12 and 13. Reload the script and observe that the command now registers.
  3. Un-comment lines 12 and 13, but replace all instances of foo() in the command to foo2(). Reload the script and observe that the command now registers.
  4. Run the effect command !bar(me). Observe how the function is registered, and the player receives a single cobblestone item. This is despite bar() utilizing the foo() function that would otherwise break a command structure.

Errors or Screenshots

https://gist.github.com/2clist/18a2e7d114a7ff03111644e6b1c4f856

Other

No response

Agreement

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugAn issue that needs to be fixed. Alternatively, a PR fixing an issue.functionsRelated to functionspriority: lowIssues that are not harmful to the experience but are related to useful changes or additions.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions