-
Notifications
You must be signed in to change notification settings - Fork 295
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
VarType equality check #5616
Comments
💡 there has to be a way to make that quick-fix readily applicable to any (without there necessarily being an inspection result) |
I understand the use of warning against direct comparison to |
The real problem is that the
This naive approach probably should be converted into something like this:
In that example, we needed to change the check for both The point being, it's easy to get the usage of |
Also to be taken into account: non-equality checks involving a |
What
An inspection that locates call sites for the
VBA.Information.VarType
function, and flags a direct=
check as problematic when the operand isVbVarType.vbArray
. Although, it probably doesn't hurt to flag any direct=
comparison from the return value ofVBA.Information.VarType
, either.Why
The enum value returned by the
VarType
function requires bitwise comparison to evaluate as intended: as written, the condition is systematically false given aVariant()
(variant array) value, because what's returned is a compound value that boils down tovbArray+vbVariant
.Example
This code should trigger the inspection:
QuickFixes
Convert to bitwise comparison
Example code, after quickfix is applied:
Resources
Each inspection needs a number of resource strings - please provide a suggestion here:
VarTypeComparisonInspection
The text was updated successfully, but these errors were encountered: