Closed AstrocalcVB closed 3 years ago
Thanks for the report, that special-form syntax is ...apparently not quite there yet!
We have a special grammar rule for Circle
: https://github.com/rubberduck-vba/Rubberduck/blob/a707020343a71bc5bf9b700b339c7c2deb858c67/Rubberduck.Parsing/Grammar/VBAParser.g4#L581
It's expecting expressions after every comma, which is not what you have here. In theory the grammar rule could be adapted to allow for empty expressions, which would match the optional argument usage.
If we'd attempt to be strict, we might adapt the grammar rule to deal with the full syntax as specified in this documentation:
expression.Circle [Step](x,y), radius [, [color][, [start][, [end][, aspect]]]]
Long story short we have the current rule, except that we note that the arguments 2-4 are optional (if given). A simpler alternative would be to make all arguments optional :) The simplest fix would be to make the expression
in the rule optional. That of course might require some adjustments to the resolver.
Tangentially related: #4875. We may want to validate that other special form parsing rules also account for optional arguments correctly.
Worth noting that radius
is required.
I was able to reach some progress, but still ended up in error.
Starting with removing all the optional arguments where code is Printer.Circle (varX, varY), varRad, , , , 1 as default for last argument is 1.0 anyway, and also commenting out the ones that has a variable at position for last optional argument, but in some cases the first optional argument has a variable and I left it intact. Result: Still a parse error, but this time log didn't pin point line and column for where the error was triggered, only the module.
So next I commented out all optional argument, leaving only Printer.Circle (varX, varY), varRad (or frm.Circle ...) and this cleared the way to complete the parse w/o error.
However, soon after I got a resolve error when rd was trying to "Resolve Declarations". Soon after the VB6 IDE died. I'm just posting the first error line from log here as I don't know if this should go in a separate issue or not?
2021-05-17 14:13:14.1319;ERROR-2.5.2.5920;Rubberduck.Parsing.VBA.DeclarationResolving.DeclarationResolveRunnerBase;Exception thrown acquiring declarations for 'Astrocalc.XAPI2000' (thread 3).;System.OutOfMemoryException: Exception of type 'System.OutOfMemoryException' was thrown.
I was monitor memory consumption in Windows Task Manager during the process, if it could be of value. After start and load of project VB6.exe consumed about 100MB but while the rd parser was running this grew to about 1140MB before the IDE crash. My system has 32 GB installed RAM.
@AstrocalcVB how many modules (& what size) and referenced libraries are we looking at? Memory usage is definitely an area Rubberduck needs to improve... and we need a quick "project size" metric that can help us put things in perspective.
Not sure how much of a dent it can make, but disabling all inspections could help, especially if some of them are spawning thousands of results (Hungarian Notation / Use Meaningful Names, Implicit Public accessors & ByRef modifiers, etc.)
@AstrocalcVB how many modules (& what size) and referenced libraries are we looking at? Memory usage is definitely an area Rubberduck needs to improve... and we need a quick "project size" metric that can help us put things in perspective.
It's a fairly big project and maybe I should have mentioned that I also have CodeSmart 2013 installed, although it shouldn't really matter. So, I will pull some of the figures out that I get when running its Code Statistics routine:
Total Lines: 141,521 Code Lines: 96,474 (68.17%) Comment Lines: 18,100 (12.79%) Blank Lines: 26,947 (19.04%)
Total members: 5028 Public Events: 63 Properties: 454 Methods: 4,511
Total Controls Used: 2761 Components: 129 Modules: 28 Classes: 30 Forms: 71
Not sure how much of a dent it can make, but disabling all inspections could help, especially if some of them are spawning thousands of results (Hungarian Notation / Use Meaningful Names, Implicit Public accessors & ByRef modifiers, etc.)
I haven't changed anything in settings since installation, except LogLevel, and no Windows have been activated in "Windows Settings". I did untick "Run inspectors automatically on successful parse" and that seems to render a somewhat different result in that "Resolving Declarations..." disabled button caption remains disabled (for quite some time) until IDE finally crashes.
Log file has several hundred lines of these:
2021-05-17 17:51:05.4222;WARN-2.5.2.5920;Rubberduck.Parsing.VBA.ReferenceManagement.CompilationPasses.TypeAnnotationPass;Failed to resolve type IStdDataFormatDisp; 2021-05-17 17:51:05.4222;WARN-2.5.2.5920;Rubberduck.Parsing.VBA.ReferenceManagement.CompilationPasses.TypeAnnotationPass;Failed to resolve type DataSource; 2021-05-17 17:51:05.4222;WARN-2.5.2.5920;Rubberduck.Parsing.VBA.ReferenceManagement.CompilationPasses.TypeAnnotationPass;Failed to resolve type IStdDataFormatDisp; 2021-05-17 17:51:05.4222;WARN-2.5.2.5920;Rubberduck.Parsing.VBA.ReferenceManagement.CompilationPasses.TypeAnnotationPass;Failed to resolve type DataSource; 2021-05-17 17:51:05.4372;WARN-2.5.2.5920;Rubberduck.Parsing.VBA.ReferenceManagement.CompilationPasses.TypeAnnotationPass;Failed to resolve type VBControl; 2021-05-17 17:51:05.4372;WARN-2.5.2.5920;Rubberduck.Parsing.VBA.ReferenceManagement.CompilationPasses.TypeAnnotationPass;Failed to resolve type VBControl;
and then 2021-05-17 17:51:25.0580;ERROR-2.5.2.5920;Rubberduck.Parsing.VBA.ReferenceManagement.ReferenceResolveRunnerBase;Exception thrown on resolving those modules: (here listing basically every module in project, followed by) ;System.OutOfMemoryException: Exception of type 'System.OutOfMemoryException' was thrown.
I now see the Circle issue, which is the bug I reported, has been solved. So, I will simply try with a smaller project so I hopefully can reach the state of seeing what RD actually can do and get more feeling for it. Also, it's the Unit testing I'm mostly interested in as I already have CS2013, but if RD make a better job where they overlap, great.
OK success completing parse on a somewhat smaller project. Will return to this larger project once I have a better understanding of RD and filing issue when I can do so meaningfully.
Rubberduck version information The info below can be copy-paste-completed from the first lines of Rubberduck's log or the About box:
Description Fresh install of RD, first time ever. I'm clicking the "Pending" button in the toolbar, and after a short moment it comes back from disabled state with the caption "Parse Error". I have attached the log file, which shows the error is triggered in several modules and from what I have been able to figure out the trigger is always a code line with Printer.Circle in format as below.
Printer.Circle (varX, varY), varRad, , , , 1
To Reproduce Steps to reproduce the behavior:
Expected behavior Expect the code to be parsed.
Screenshots If applicable, add screenshots to help explain your problem.
Logfile
RubberduckLog.txt
Additional context The errors seems to consume a lot of memory as after, when trying to open the Rubberduck About menu item, I get an error from .NET "Unhandled exception has occured in a component in your application. (none important text) Not enough memory resourses are available to process this command. (Exception from HRESULT: 0x80070008"
There are then about 500 lines of exception text, but not sure if it's really relevant here so I'm not posting it, unless requested.