You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* Add warning for ambiguous arg subtraction
* optimize condition and check if the second literal is specifically 1.
* Update src/main/java/ch/njol/skript/expressions/arithmetic/ExprArithmetic.java
if (operator == Operator.SUBTRACTION && !rightGrouped && !leftGrouped// if the operator is '-' and the user didn't use ()
303
+
&& firstinstanceofExprArgumentargument && argument.couldCauseArithmeticConfusion() // if the first expression is 'arg'
304
+
&& secondinstanceofExprArithmetic<?, ?, ?> secondArith && secondArith.firstinstanceofLiteral<?> literal// this ambiguity only occurs when the code is parsed as `arg - (1 * 2)` or a similar PEMDAS priority.
Skript.warning("This subtraction is ambiguous and could be interpreted as either the 'first argument' expression ('argument-1') or as subtraction from the argument value ('(argument) - 1'). " +
312
+
"If you meant to use 'argument-1', omit the hyphen ('arg 1') or use parentheses to clarify your intent.");
0 commit comments