Skip to content
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

'@Ignore ImplicitByRefModifier doesn't work with a line continuation #4926

Open
daFreeMan opened this issue Apr 18, 2019 · 3 comments
Open
Labels
bug Identifies work items for known bugs

Comments

@daFreeMan
Copy link
Contributor

Rubberduck version information
Version 2.4.1.4666
OS: Microsoft Windows NT 10.0.15063.0, x64
Host Product: Microsoft Office 2016 x64
Host Version: 16.0.4822.1000
Host Executable: EXCEL.EXE

Description
Adding '@Ignore ImplicitByRefModifier to a function declaration does not work if there is a line continuation (_) in the declaration.

To Reproduce
Steps to reproduce the behavior:

  1. Write a function declaration with an implicit ByRef
  2. Edit in a line continuation
  3. Use the Code Inspection QuickFix Ignore Once
  4. Parse
  5. See error

Expected behavior
It works just fine without the line continuation, it should work equally well with the line continuation

Logfile
RubberduckLog.txt

Additional context
This code:

'@Ignore ImplicitByRefModifier
    Private Declare PtrSafe Function GetUserName Lib "advapi32.dll" Alias "GetUserNameA" (ByVal IpBuffer As String, nSize As Long) As Long
'@Ignore ImplicitByRefModifier
    Private Declare PtrSafe Function GetComputerName Lib "kernel32" Alias "GetComputerNameA" _
                             (ByVal lpBuffer As String, nSize As Long) As Long

Generates one Parameter 'nSize' is implicitly passed by reference inspection on the second declaration (GetComputerName).

This, however, does not generate an inspection result for either variation:

'@Ignore ImplicitByRefModifier
Private Function foo(bar As Long) As Long
  foo = 1
End Function

'@Ignore ImplicitByRefModifier
Private Function bar(foo As Long) _
    As Long
  bar = 2
End Function
@daFreeMan daFreeMan added the bug Identifies work items for known bugs label Apr 18, 2019
@Vogel612
Copy link
Member

Yea, I assume that's because a part of the logic for ignore annotations may fall back to checking the annotation based on the module's lines as retrieved from the VBE, which only respects physical lines, not logical lines...

@MDoerner
Copy link
Contributor

Quite exactly. If there is any physical line with code in between, an annotation does not apply. This is how annotations currently work.

@daFreeMan
Copy link
Contributor Author

daFreeMan commented Apr 19, 2019

@MDoerner I'm not quite sure I buy that logic - in the simple code I provided at the end, the 2nd @Ignore does work. i.e. there is no inspection generated on Function bar.

I see the difference in the declarations. If I put the _ before (foo As Long), I do get the false positive inspection.

@Vogel612 Vogel612 added the hacktoberfest Tags issues for Hacktoberfest 2019 label Sep 20, 2019
@bclothier bclothier removed the hacktoberfest Tags issues for Hacktoberfest 2019 label Nov 5, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Identifies work items for known bugs
Projects
Development

No branches or pull requests

4 participants