Type Hints for expressions #5004
TheLimeGlass
started this conversation in
General
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I was thinking this is probably possible, but expensive to do.
There could be type hints for expressions, and if a value is unknown at parse time. Say
damage cause %object%
well we can get all the possible events used where the expression is, and if damage cause doesn't exist in any of the events, then Skript would error.Ok another example would be getting a dedicated block type or entity, like an armour stand, lets get the arms of an armour stand. An expression to get the angle of the arms is present in an armour stand manipulate event.
arms of %entities%
if the expression used the event-entity which is an armour stand, the expression can error if it wasn't an armour stand at parse time because the event has to be an armour stand, same can go foron damage of armour stand
we know it has to be an armour stand. There is a lot of access required to get these checks, but it's possible for creating errors in some cases.Things like functions won't have a reference, so type hints can't be used with an event there.
How this could be done, would be like looping all the methods of the possible events, and get their return types. Reflection, being pretty expensive, but would avoid a large amount of issues we have with parse to runtime.
Beta Was this translation helpful? Give feedback.
All reactions