SkriptParser incorrectly checks whether an expression in a pattern is nullable #6202
Open
1 task done
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: low
Issues that are not harmful to the experience but are related to useful changes or additions.
Skript/Server Version
Bug Description
A user on discord reported this error:
ch.njol.skript.SkriptAPIException: The class 'object' does not provide a default expression. Either allow null (with %-object%) or make it mandatory [pattern: (execute|run) function <.+> [and store it in %~-objects%]]
This is because SkriptParser only checks the first character of the input to determine if the expression is nullable. It is not guaranteed to be the first character. Other areas of Skript (e.g. TypePatternElement) account for this.
Skript/src/main/java/ch/njol/skript/lang/SkriptParser.java
Line 245 in 7178dc4
The best solution is likely to call getExprInfo and then just check whether the ExprInfo has it marked as nullable. This method does cache the input though so I'm not sure if that may be unwanted if the expression is nullable.
Expected Behavior
Skript should identify the expression as nullable and not print an error that it is does not allow null.
Steps to Reproduce
In a pattern, use a flag mask and then a nullable indicator, e.g.
%~-objects%
Errors or Screenshots
full stacktrace: https://paste.gg/p/anonymous/fba5298c26b140198e1e7db93d410497
Other
No response
Agreement
The text was updated successfully, but these errors were encountered: