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
Parse Error : Comment Line with Underscore #4196
Comments
Just to be clear, I'm assuming that the lines with In this code:
The |
Sorry, I was playing around with the _ line to get it fixed and copied one with space. Originally there is no space between ' and _ otherwise you are correct as it will be detected as line break and fails the entire function. Regarding the extra comment pointing the error lines, you are correct it is not part of the original code. So, if line below is in code which is detected by VBA as a comment line with no break., the error is raised: I tried a few cases and as soon as I added a text after underscore, there is no error. |
I can reproduce this. Here's a much smaller MVCE: This will result in a parser error even though the code can compile.
OTOH, this compiles and parses just fine:
In contrast, a space makes the code un-compilable with
Finally, if you put in a character, the code becomes compilable and is also parsable:
In conclusion, I suspect there's a issue with the grammar for handling line continuations with the comment. |
This is a grammar issue, indeed. I already have an idea how to fix this edge case. I will just need a bit of time to test it. |
@MDoerner this is a bug also, slight variation: Sub test()
If True Then
'_ _
_
End If
End Sub |
And of course a non breaking space followed by an underscore followed by a new line, is NOT a line continuation. |
@MDoerner This might prove useful when testing the change: Option Explicit
Sub test()
'_
If True Then
End If
'_ _
_
If True Then
End If
Dim dic1 As _
Dictionary
Dim dic2 As _
Scripting _
. _
Dictionary
Dim dic3 As Scripting _
. _
Dictionary
Debug.Print dic1. _
Item("a")
Debug.Print dic2 _
. _
Item("a")
Debug.Print dic3 _
. _
Item("a")
Dim x, x_
x = dic1 _
!a
x = dic2 _
! _
a
x = dic3 _
! _
a
End Sub |
I have a VBA project and trying to take advantage of rubberduck features. However, it seems that rubberduck doesn't handle one of the end-ifs in the following function.
Error Context reads as : mismatched input 'End If' expecting PABS, ANY, ARRAY, CBOOL, CBYTE, CCUR, ...}
I have also isolated only the function below into a blank/new workbook and same error happens with rubberduck. The source of issue seems to be a commented header line for if condition over line break '' character ! I tried to remove the comment header with '' in it and no more error was generated.
P.S. Option Explicit is included in the module in case that might be a question.
The text was updated successfully, but these errors were encountered: