-
-
Notifications
You must be signed in to change notification settings - Fork 4k
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
fix(BitField): throw an error if bit to resolve is undefined #5565
Conversation
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.
lgtm
Co-authored-by: Vlad Frangu <[email protected]>
I don't really think this is what we want. Taking an example where this would yield an unexpected result: A command handler. In our example no permissions would be required, maybe it's a ping command. As result you'd now need to change your command handler to use something like
Another inconsistency here is that apparently identical values would yield different results i.e. Maybe this issue here be approached by editing |
I'm not sure what to think anymore... Is this a "non-issue"? Or should we go back to the basic change where we check if bit is undefined (and incidentally if the array is empty, if one is provided). Going back to the command handler example, I, in my opinion, think we should not call |
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.
Please address the issue explained by @SpaceEEC, as this current code contains a critical bug that will make it behave in unexpected ways.
My main proposal was to return
|
The first solution is probably the best one, I mean we should not give any answer if we are not able to give one.
|
Need advice for the three last commits. |
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.
Should be good to go otherwise.
src/util/BitField.js
Outdated
@@ -38,10 +38,11 @@ class BitField { | |||
/** | |||
* Checks whether the bitfield has a bit, or multiple bits. | |||
* @param {BitFieldResolvable} bit Bit(s) to check for | |||
* @param {...*} hasParams Additional parameters for the has method, if any |
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.
I'm not sure what exactly this solves, but I'd rather drop it and the recursion that requires it.
BitField.resolve
handles arrays just fine.
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.
Without this, it used to return true whenever they had admin no matter if you actually passed true to checkAdmin.
I still do not really understand the issue here, anyway as you said <BitField>.constructor.resolve
handles arrays well already.
Please describe the changes this PR makes and why it should be merged:
Currently,
BitField.has(undefined)
orBitField.has(<BitField>.FLAGS.ANY_NON_SPECIFIED_FLAG)
returns true.Status and versioning classification:
Please move lines that apply to you out of the comment: