-
-
Notifications
You must be signed in to change notification settings - Fork 373
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
Fixed SimpleExpression#getArray() throwing an error when length of values array is 0 #6822
base: dev/patch
Are you sure you want to change the base?
Conversation
I think it may be better to check the class of the array. There's no reason to create a new array instance reflectively if the given array is of the correct type |
I also question whether this is something we should be doing at all. Really, this is due to ExprXOf violating its contract. When
|
I completely agree in principle and I spent a while trying to fix all of these bad returns in a previous PR, but what I worry is that there is no easy way to hold addons, etc. to this contract, so it's likely bad API use will slip through the net, and we either need to catch that at the first opportunity and give a proper error for it (so people know to fix it) or we need to try and accommodate it in a reasonable way, so that it doesn't error where possible. |
I would be in favor of an error |
That's fine, do you think that should be done in this PR or its own? Also, where do you think is the best place to test for the array being of the wrong (unreported) type? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Based on the discussion above, I would be in favor of (at most) catching this and erroring about an API violation. I'm not sure it's necessary for us to cover every misuse of the API (including this one), in fact I would prefer leaving the method as-is, but I understand the concern.
Description
I fixed an issue where casting empty array throws an error
Target Minecraft Versions: any
Requirements: none
Related Issues: #6817