rubberduck-vba / Rubberduck

Every programmer needs a rubberduck. COM add-in for the VBA & VB6 IDE (VBE).
https://rubberduckvba.com
GNU General Public License v3.0
1.91k stars 299 forks source link

Parsing Error With No Search Results #2918

Closed pixelvertice closed 5 years ago

pixelvertice commented 7 years ago

Hello, I'm relatively new to VBA and I recently installed Rubberduck for my CorelDRAW VBA environment. I'm using CorelDRAW X7 on Windows 7 64bit.

I tried to run Rubberduck for the first time, after doing some registry workarounds to make it load in my 64 bit IDE. It works, but I stumped by Parse Error hence leave most of Rubberduck features unusable.

Here's pastebin to the log file >> http://pastebin.com/wFwMbW6v

Thank you, looking forward to be able to use this powerful add-in..!

Vogel612 commented 7 years ago

2017-03-21 17:15:25.1471;ERROR-2.0.13.32288;Rubberduck.Parsing.VBA.ComponentParseTask;Exception thrown in thread 24, ParseTaskID 6ed1af23-86ba-4b8f-bac8-a021c2075efd.;System.ArgumentOutOfRangeException: Length cannot be less than zero.
Parameter name: length
   at System.String.Substring(Int32 startIndex, Int32 length)
   at Rubberduck.Parsing.Preprocessing.LivelinessExpression.MarkAsDead(String code) in C:\Users\Mathieu\Documents\GitHub\Rubberduck (main)\Rubberduck\Rubberduck.Parsing\Preprocessing\LivelinessExpression.cs:line 26
   at Rubberduck.Parsing.Preprocessing.LivelinessExpression.Evaluate() in C:\Users\Mathieu\Documents\GitHub\Rubberduck (main)\Rubberduck\Rubberduck.Parsing\Preprocessing\LivelinessExpression.cs:line 21
   at Rubberduck.Parsing.Preprocessing.ConditionalCompilationIfExpression.Evaluate() in C:\Users\Mathieu\Documents\GitHub\Rubberduck (main)\Rubberduck\Rubberduck.Parsing\Preprocessing\ConditionalCompilationIfExpression.cs:line 48
   at Rubberduck.Parsing.Preprocessing.ConditionalCompilationBlockExpression.<>c.<Evaluate>b__2_0(IExpression child) in C:\Users\Mathieu\Documents\GitHub\Rubberduck (main)\Rubberduck\Rubberduck.Parsing\Preprocessing\ConditionalCompilationBlockExpression.cs:line 17
   at System.Linq.Enumerable.WhereSelectListIterator`2.MoveNext()
   at System.String.Join(String separator, IEnumerable`1 values)
   at Rubberduck.Parsing.Preprocessing.ConditionalCompilationBlockExpression.Evaluate() in C:\Users\Mathieu\Documents\GitHub\Rubberduck (main)\Rubberduck\Rubberduck.Parsing\Preprocessing\ConditionalCompilationBlockExpression.cs:line 17
   at Rubberduck.Parsing.Preprocessing.VBAPreprocessor.Execute(String moduleName, String unprocessedCode, CancellationToken token) in C:\Users\Mathieu\Documents\GitHub\Rubberduck (main)\Rubberduck\Rubberduck.Parsing\Preprocessing\VBAPreprocessor.cs:line 24
   at Rubberduck.Parsing.VBA.ComponentParseTask.RewriteAndPreprocess(CancellationToken token) in C:\Users\Mathieu\Documents\GitHub\Rubberduck (main)\Rubberduck\Rubberduck.Parsing\VBA\ComponentParseTask.cs:line 184
   at Rubberduck.Parsing.VBA.ComponentParseTask.Start(CancellationToken token) in C:\Users\Mathieu\Documents\GitHub\Rubberduck (main)\Rubberduck\Rubberduck.Parsing\VBA\ComponentParseTask.cs:line 51

It seems there is an error with the processing of "preprocessor directives" (well the name isn't strictly correct, but eh...). The point is, somewhere in your code there is something that looks like this:

#If <text here> Then

#Else 

#EndIf

This is what currently trips rubberduck up. If you could try to reproduce the parse-error with either a "minimal example" by removing code that doesn't produce the error and attaching the result here or possibly (check with your company) share the module where the parse-error is located, we can find a fix for this. Thanks :)

Vogel612 commented 7 years ago

There are some additional parse-errors, namely in the modules: frmTiling, frmProgress, frmCTP and CSVReader. Are you 100% sure that the code does compile and work, especially on all precompiler-directive combinations?

ThunderFrame commented 7 years ago

When I use Rubberduck in CorelDRAW X6, I have to unload all of the GlobalMacros as at least one of the GlobalMacros has something that is causing a ParserError, and I haven't been able to work out what it is yet.

pixelvertice commented 7 years ago

Okay so I tried to narrow the error down by unloading some macro project from my IDE (most of it are downloaded macros), leaving only my projects open. From my project I found some modules are causing trouble to the parser, those modules are snippets from the internet. I tried to remove those modules then refresh the parser, then it can complete its task successfully.

Here's the problematic modules: JsonConverter: https://github.com/VBA-tools/VBA-JSON CSVReader: http://www.freevbcode.com/ShowCode.asp?ID=7655

@ThunderFrame my Global Macros are empty, so it's not the case for me

comintern commented 7 years ago

@pixelaminator - Did you import CSVReader, or did you copy and paste the code? Looks like these might be causing problems:

VERSION 1.0 CLASS
BEGIN
  MultiUse = -1  'True
  Persistable = 0  'NotPersistable
  DataBindingBehavior = 0  'vbNone
  DataSourceBehavior  = 0  'vbNone
  MTSTransactionMode  = 0  'NotAnMTSObject
END
Attribute VB_Name = "CSVParse"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = False
pixelvertice commented 7 years ago

I copy pasted it, but I leave that declaration part because my project wouldn't run with it. So those declaration part is not in my code

retailcoder commented 7 years ago

@pixelaminator the VBE doesn't display module and member attributes, but they're important nonetheless. That's why it's best to import modules, so that attributes are picked up by the editor. They won't compile if pasted into a code pane.

MDoerner commented 5 years ago

This has long been fixed (since PR #3001).

I tested with the code from both links and there is no problem.