-
-
Notifications
You must be signed in to change notification settings - Fork 393
Variables can be used as function arguments of the wrong type #1229
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
Comments
Seems to be working as intended. Variables are not type-safe. Does this occur if you directly give the expression as function parameter? It is a bit stupid that even local variables do not remember their types. Changing that would probably be a good idea. But separate issue for that, if needed. |
This is certainly not intended behavior. It is a side effect of Converters#convert returning null if conversion fails or is not possible -- what used to be stopped because of the null prevention is now allowed to go through. Obviously, variables do not have a known type at parse time, however this is actually a runtime issue where the type can be derived. |
Why do you think that it is not intended behavior? It is not like function parameters would have wrong types; they are just not available. Of course, this could lead to cryptic errors. So could not calling the function do. In this case, you can at least add debug messages inside the function to check what parameter has trouble. |
because if i call a function with the wrong type it shouldnt be called... |
I'm not sure where you have got that idea. Other syntax elements are called, too, and may cause unpredictable effects when you mistype variables. Having functions work that way and not silently do nothing seems to make most sense. I think current default is lesser evil: your function is always called when you ask for that. You don't need to consider that it might have not been called at all while debugging. Making local variables know their type should be possible. It would at least partially solve this issue and generally be helpful. |
This "issue" is just the direct consequence of variables being dynamically typed. Yes, pretty much nothing is type-safe. But that's part of Skript's design, and dynamic typing in general. If you don't like it, then go ahead and make variables statically typed. But I don't think this is very good in Skript. |
no, other syntax elements are not called. if at runtime your syntax is given the incorrect type it will not be called. |
Well, it could just achieve the same effect in case none of the elements inside the function actually runs. |
I thought functions weren't erroring at all for incorrect types. It's just variables and in my case player but console was executing the command. Too ambiguous to be doing right now. Unassigning. A runtime error could be implemented to let the scripter know. Functions already have some runtime errors implemented. |
Related #3864 |
test should never be called, but because null values are now accepted, it will get called with null
The text was updated successfully, but these errors were encountered: