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

Recent Resolver Error on VBE-compilable code #6187

Open
pflugs30 opened this issue Dec 10, 2023 · 5 comments
Open

Recent Resolver Error on VBE-compilable code #6187

pflugs30 opened this issue Dec 10, 2023 · 5 comments
Labels
bug Identifies work items for known bugs

Comments

@pflugs30
Copy link
Contributor

Rubberduck version information
The info below can be copy-paste-completed from the first lines of Rubberduck's log or the About box:

Version 2.5.9.6314
OS: Microsoft Windows NT 10.0.22631.0, x64
Host Product: Microsoft Office x64
Host Version: 16.0.16130.20846
Host Executable: EXCEL.EXE

Description
After updating to the recent public release of Rubberduck, I started seeing a Resolver Error on compilable code which used to be just fine. Using the log files, I isolated the issue to a single method.

To Reproduce
Steps to reproduce the behavior:

  1. Open Excel and create a new blank workbook.
  2. Open the VBE and add a single code module.
  3. Paste the following code: Module1.zip
  4. Compile the code to show the VBE can parse it.
  5. Click the Rubberduck menu --> Refresh
  6. Observe Rubberduck will show a Resolver Error.

Expected behavior
Rubberduck should be able to parse and resolve this code just fine.

Screenshots
N/A

Logfile
RubberduckLog.txt

Additional context
Specifically, I've discovered these lines to be the problem:

        If utc_HasOffset Then
            ParseIso = ParseIso - utc_Offset
        End If

When these lines are commented, then RD can parse and resolve all day. All these variables are defined and found in the function.

@pflugs30 pflugs30 added the bug Identifies work items for known bugs label Dec 10, 2023
@MDoerner
Copy link
Contributor

Thanks for the report.
I think I have an idea why there is an exception in the resolution. However, if that code is the culprit, I think something imight be already wrong when parsing the code. The resolver seems to fail on a single line if statement with empty then statement.

I will have a look later and see what I can do.

@pflugs30
Copy link
Contributor Author

Please let me know if you'd like me to send a broader log file. I think what I sent covers the parsing, but I could be mistaken.

@jimmyli97
Copy link

If anyone else has this issue then the workaround for now is to remove the empty line e.g. If utc_NegativeOffset Then utc_Offset = -utc_Offset instead of If utc_NegativeOffset Then: utc_Offset = -utc_Offset

@Irubataru
Copy link

I am also having this issue, but my code base is massive and I can't really fix it with workarounds. I am trying to find a usable version of Rubberduck. Due to #6152 I also can't use v2.5.9.6291. I tried v2.5.2.6260-pre, but I am having some performance issues with that release.

tommy9 added a commit to tommy9/Rubberduck that referenced this issue Jan 27, 2024
@tommy9
Copy link
Member

tommy9 commented Jan 27, 2024

I've submitted a pull request with a fix. For reference here, a simplified error case is shown below with explanation of how the parse went wrong in the comments:

Sub test()
    If True Then: A = 1 'matches an ifStmt incorrectly but only when have an ifStmt later

    If False Then       'when above goes wrong, this is matched as singleLineIfStmt with empty THEN clause which is wrong. If that didn't happen, the above would not match ifStmt and then try to match singleLineIfStmt as it should
        A = 5
    End If
End Sub

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
Status: To triage
Development

No branches or pull requests

5 participants