Rubberduck icon indicating copy to clipboard operation
Rubberduck copied to clipboard

Frequent, inconsistent parse errors

Open masebu opened this issue 2 years ago • 2 comments

Hi,

I discovered Rubberduck about a year ago and I like it a lot (folders, annotations, inspections, indent, export/import, ...); thank you for that project. However, I have an issue that makes it practically unusable for the projects where I need it most (and I miss Rubberduck the minute I can't use it).

Thanks, sebastien

Rubberduck version information

Version 2.5.2.5984 OS: Microsoft Windows NT 10.0.19043.0, x64 Host Product: Microsoft Office x64 Host Version: 16.0.14430.20234 Host Executable: EXCEL.EXE

I've had the problem with different versions over the past year.

Description

Rubberduck works very nicely for small projects. Anytime my vba projects grow, Rubberduck begins to fail to parse them. My current project is ~15 modules; maybe 2 of them are over 500 lines but below 1000. I believe that's still very modest.

Rubberduck gives inconsistent errors:

  • on parse 1 it will detect errors in 3 modules
  • on parse 2 it will detect an error in 1 other module but not the first 3
  • on parse 3 again on a different module, or maybe again one the previous ones
  • at some point it might suddenly parse the project OK... then on next refresh fail again

Other notes:

  • Parsing the project (and failing) made the memory footprint grow ~600MB, not sure if that's expected.
  • I believe that for a given module, the error is always the same at all refreshes - not sure across sessions
  • parse errors happen on the smaller modules as much as on the bigger ones

Rubberduck parsed my current project perfectly at the begining. Then it began failing from time to time, a refresh or two would do the trick. A week later it's unusable, I may need 20 refreshes before it parses well.

I have created a new workbook and imported my project from files, it still fails. I made sure the project compiles.

To Reproduce

Steps to reproduce the behavior:

  1. Open xlsm file
  2. Open vba editor
  3. Click Refresh in Code Editor
  4. get parse errors in the line of mismatched input, extraneous input, no viable alternative at input...
  5. Repeat

Expected behavior

Parse succeeds (or at least gives real, consistent errors)

Screenshots

Below are screenshots from 3 successive parses, no change to code in between image image image

Logfile

Logfile created with initial refresh + 2 subsequent refreshes (not related to above screenshots) RubberduckLog.20211008T1940+0200.txt

Additional context

I'm not an admin on my machine, Rubberduck is installed in user mode. I have an autoloaded xlam that I know is horrible, Rubberduck is set to ignore it, so it's not supposed to interfere. I use vba on and off, I'm not the best at it. I have not tried recently on a different machine. I can't remember if I tried last year when that first happened.

masebu avatar Oct 08 '21 17:10 masebu

Thanks for reporting this.

I had a look at the log. This issue has something to do with exported version of the code, which we use to identify attributes. There are no parser errors at all for the code pane version, i.e. what you see in the VBE.

My guess is that there is something that sometimes prevents us from correctly parsing an attribute. Could you export one of the modules in the log and tell us what is on the offending line and which attributes the function containing the line has? One example would be line 32 of the exported version of the module FSUtils, another line 26 of the exported module PathHandlers.

Knowing this would help us debug this issue. However, I would also understand if you were not willing to disclose this code publicly.

MDoerner avatar Oct 08 '21 22:10 MDoerner

Hi,

Thank you for your interest

no problem with sharing code, there's nothing confidential

FSUtils.line32 and PathHandlers.line26 are indeed Attributes:

exerpt from FSUtils

(...)
30 '@Description("shortcut to get a disposable FileSystemObject")
31 Public Function fso() As FileSystemObject
32 Attribute fso.VB_Description = "shortcut to get a disposable FileSystemObject"
33
34   Set fso = New FileSystemObject
35
36 End Function
(...)

exerpt from PathHandlers

(...)
24 '@Description("The base working directory (subfolders: original extracts + regions")
25 Function BuildBaseWorkDirPath(Optional ByVal bIgnoreSubst As Boolean = False) As String
26 Attribute BuildBaseWorkDirPath.VB_Description = "The base working directory (subfolders: original extracts + regions"
27 
28   ' try to apply subst if applicable
29   If Not (bIgnoreSubst) And IsApplyBaseWorkDirSubst() Then
(...)

FSUtils+PathHandlers.WithAttributes.zip

Since your comment, I recreated the project from scratch (based on an xlsx version of the book) by importing cleaned-up sources from which all attributes (except Attribute VB_Name = "<moduleName>") and all annotations (except @Folder) had been removed. Unfortunately I get the same results.

Then I tried recreating the project from scratch again (still from an xlsx version) and importing the modules one by one. I start getting the errors with my third module (Winmerge.bas). The log still says it fails on the AttributesCode version of the module, but that time the line (L28C27) is just a comment. Below is the log of that try and the source for the failing module. (it finally parsed on the third or fourth refresh) log+Winmerge.NoAttributesNoAnnotations.zip

Thanks for your help

masebu avatar Oct 09 '21 09:10 masebu