Skip to content
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

Cannot do arithmetic involving 2 or more return value functions #3046

Closed
peytonr110105 opened this issue Jun 11, 2020 · 2 comments
Closed

Cannot do arithmetic involving 2 or more return value functions #3046

peytonr110105 opened this issue Jun 11, 2020 · 2 comments
Labels
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. priority: lowest "Nice to have" updates that are not required (tiny low impact bug fixes or QoL enhancements).

Comments

@peytonr110105
Copy link

Description

When attempting to perform any math operation that involves multiple return-value functions, Skript throws an error and the operation fails.

Steps to Reproduce

  1. Create a function that returns a number.
  2. Attempt to perform any math operation that calls the function more than once.
  3. Skript will report an error that "functions cannot be used here". The math operation will not be performed.

Sample Error:

[17:39:50 ERROR]: Functions cannot be used here (or there is a problem with your arguments). (testscript.sk, line 6: set {_test} to getANumber() + getANumber()')

Server Information

Server version/platform: Paper 1.12.2-1606
Skript version: 2.4.1 & 2.5-alpha-3
Tested with no addons installed.

Additional Context

Here is the test script I created to demonstrate this issue:

function getANumber() :: number:
return 2

command /testFuncReturn:
trigger:
set {_test} to getANumber() + getANumber()
send "%{_test}%" to the player

The command should send the number 4 to the player, but instead sends nothing.

@Whimsyturtle Whimsyturtle added bug An issue that needs to be fixed. Alternatively, a PR fixing an issue. priority: lowest "Nice to have" updates that are not required (tiny low impact bug fixes or QoL enhancements). labels Jul 10, 2020
@APickledWalrus
Copy link
Member

Might be worth mentioning that the following parses and works correctly:

function getNum() :: number:
    return 10

set {_result} to getNum() + getNum() + 1

@TPGamesNL
Copy link
Member

This is caused by SkriptParser#parseFunction(Class...), since it attempts to parse as a function call:
myFunc() + myFunc()
******^...........^

With ) + myFunc( being the argument(s) for the function.

@TPGamesNL TPGamesNL added the PR available Issues which have a yet-to-be merged PR resolving it label Mar 27, 2021
@FranKusmiruk FranKusmiruk added completed The issue has been fully resolved and the change will be in the next Skript update. and removed PR available Issues which have a yet-to-be merged PR resolving it labels May 9, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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. priority: lowest "Nice to have" updates that are not required (tiny low impact bug fixes or QoL enhancements).
Projects
None yet
Development

No branches or pull requests

6 participants