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
Inconsistent false positive on 'passed ByVal and assigned a value' inspection #4030
Comments
This is not inconsistent, but still wrong. In the code snippet, for some reason the inspection thinks that the member |
Hmm, so a resolver bug more than an inspection issue then? |
Could also be an artifact of how the older inspections kind of tried to do the resolver's job - this looks like it could be a case of the inspection not using the resolved member call; investigation is needed. |
It is the resolver. The inspection just looks for by value parameters with an assignment reference. |
The problem seems to be that member access resolution generally fails for members of parameters. More precisely, the |
I'm going to go out on a limb and say it is inconsistent. After noting the conversation, and especially the comment about the MCVE not having the Variant parameter, I made this: Public Sub foo(ByVal myRange As Range, ByVal value As Variant)
myRange.value = "Bar"
End Sub and it does not generate the error. More food for thought. |
Are you sure your code snippet triggers the inspection? I do not get the inspection result for the snippet. |
The MCVE does not generate the error, but my real code most certainly does. Maybe this has been obvious to the two of you, but it just hit me. The inspection is legit - I'm passing However, the parameter is an object, so passing the pointer to the object ByVal really shouldn't be picked up by the inspection when I'm assigning to a property of said object, only if I'm trying Right? |
@daFreeMan no, you're not assigning the |
Is there anything else in the method that could trigger the inspection? I cannot reproduce the issue with the snippet provided, i.e. the following code does not cause an inspection result for me, neither in a standard module nor in a class module. Public Sub SetSummaryCell(ByVal SummaryRange As Range, ByVal value As Variant, ByVal FormatFlag As String)
SummaryRange.value = CStr(value)
'other stuff
End Sub |
Win10, Excel2016 (desktop), RD .3280
Generates no inspection. However, my real code (snippet):
generates the inspection.
The text was updated successfully, but these errors were encountered: