Open balloonpopper opened 1 year ago
This is going to be difficult to deal with; in fact, it's a bit of a slippery slope, since some/most ESCScript operators (e.g. eq
, lt
, etc.) aren't screened for if you use them as arguments, as you've seen above. We'd have to screen every argument for such things. We may have to live with that possibility.
That said, actually screening for a valid condition follows the current regex:
const REGEX = \
'^(?<is_negated>!)?(?<comparison>eq|gt|lt)? ?(?<is_inventory>i\/)?' + \
'(?<is_activity>a\/)?(?<flag>[^ ]+)( (?<comparison_value>.+))?$'
Technically you don't need an operator to start a group condition, i.e. [rock_with_bug]
is valid since you just want to check that it's true.
I think we may have to discuss this further and arrive at some form of compromise.
As we've noted previously, dealing with a regular language is rather difficult when it comes to doing syntax checking. When we move to a context-free language, such things are easier to do (as you've seen). For now, it may be about what we can live with, including deciding how much rope we're comfortable giving devs to hang themselves with.
Describe the bug I had this (incorrect) code as a script line and rather than it not parsing, it processed but was processed incorrectly.
To Reproduce Use the wrong format for a numerical comparrison eg
instead of
Instead of erroring about syntax, the log shows
ESC (2023-01-02T15:45:07) D esc_condition.gd: Checking if global value rock_with_bug is true ESC (2023-01-02T15:45:07) D esc_condition.gd: It isn't
Expected behavior I think this should error based on incorrect syntax.
Screenshots If applicable, add screenshots to help explain your problem.
Versions
Additional context Add any other context about the problem here.