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

Parse error in 2.1.1981 #3146

Closed daFreeMan closed 7 years ago

daFreeMan commented 7 years ago

In Access2010 on Win7 with RD 2.1.1981, I'm getting a Parse Error on code that compiles cleanly.

RubberduckLog 2.1.1981.txt

Parsing the exact same Access project with RD 2.0.13 is successful.

RubberduckLog 2.0.13.txt

On the bright side, I'm not getting the crash reported in #3145, and the MSACCESS.EXE process does terminate when I close Access using 2.1.1981!

retailcoder commented 7 years ago

Lots of SLL mode failures, this looks like the actual parser error:

2017-07-18 16:43:12.9467;DEBUG-2.0.14.29721;Rubberduck.Parsing.Symbols.SyntaxErrorException;Antlr4.Runtime.NoViableAltException: Exception of type 'Antlr4.Runtime.NoViableAltException' was thrown.
   at Antlr4.Runtime.Atn.ParserATNSimulator.HandleNoViableAlt(ITokenStream input, Int32 startIndex, SimulatorState previous)
   at Antlr4.Runtime.Atn.ParserATNSimulator.ExecATN(DFA dfa, ITokenStream input, Int32 startIndex, SimulatorState initialState)
   at Antlr4.Runtime.Atn.ParserATNSimulator.ExecDFA(DFA dfa, ITokenStream input, Int32 startIndex, SimulatorState state)
   at Antlr4.Runtime.Atn.ParserATNSimulator.AdaptivePredict(ITokenStream input, Int32 decision, ParserRuleContext outerContext, Boolean useContext)
   at Antlr4.Runtime.Atn.ParserATNSimulator.AdaptivePredict(ITokenStream input, Int32 decision, ParserRuleContext outerContext)
   at Rubberduck.Parsing.Grammar.VBAParser.mainBlockStmt() in C:\projects\rubberduck\Rubberduck.Parsing\Grammar\VBAParser.cs:line 1783;
2017-07-18 16:43:12.9507;DEBUG-2.0.14.29721;Rubberduck.Parsing.Symbols.SyntaxErrorException;Token: , (L106C48);
2017-07-18 16:43:12.9507;WARN-2.0.14.29721;Rubberduck.Parsing.VBA.ComponentParseTask;Syntax error; offending token ',' at line 106, column 48 in module Quarterly Report.LoadData.;
2017-07-18 16:43:12.9507;ERROR-2.0.14.29721;Rubberduck.Parsing.VBA.ComponentParseTask;Exception thrown in thread 6, ParseTaskID 6973b95f-85d1-4b38-a2ee-49bd0a2d7389.;Rubberduck.Parsing.Symbols.SyntaxErrorException: no viable alternative at input '.ListObjects.Add(xlSrcRange, .UsedRange, ,' ---> Antlr4.Runtime.NoViableAltException: Exception of type 'Antlr4.Runtime.NoViableAltException' was thrown.
   at Antlr4.Runtime.Atn.ParserATNSimulator.HandleNoViableAlt(ITokenStream input, Int32 startIndex, SimulatorState previous)
   at Antlr4.Runtime.Atn.ParserATNSimulator.ExecATN(DFA dfa, ITokenStream input, Int32 startIndex, SimulatorState initialState)
   at Antlr4.Runtime.Atn.ParserATNSimulator.ExecDFA(DFA dfa, ITokenStream input, Int32 startIndex, SimulatorState state)
   at Antlr4.Runtime.Atn.ParserATNSimulator.AdaptivePredict(ITokenStream input, Int32 decision, ParserRuleContext outerContext, Boolean useContext)
   at Antlr4.Runtime.Atn.ParserATNSimulator.AdaptivePredict(ITokenStream input, Int32 decision, ParserRuleContext outerContext)
   at Rubberduck.Parsing.Grammar.VBAParser.mainBlockStmt() in C:\projects\rubberduck\Rubberduck.Parsing\Grammar\VBAParser.cs:line 1783
   --- End of inner exception stack trace ---
   at Rubberduck.Parsing.Symbols.ExceptionErrorListener.SyntaxError(IRecognizer recognizer, IToken offendingSymbol, Int32 line, Int32 charPositionInLine, String msg, RecognitionException e) in C:\projects\rubberduck\Rubberduck.Parsing\Symbols\ExceptionErrorListener.cs:line 10
   at Antlr4.Runtime.ProxyErrorListener`1.SyntaxError(IRecognizer recognizer, Symbol offendingSymbol, Int32 line, Int32 charPositionInLine, String msg, RecognitionException e)
   at Antlr4.Runtime.Parser.NotifyErrorListeners(IToken offendingToken, String msg, RecognitionException e)
   at Antlr4.Runtime.DefaultErrorStrategy.NotifyErrorListeners(Parser recognizer, String message, RecognitionException e)
   at Antlr4.Runtime.DefaultErrorStrategy.ReportNoViableAlternative(Parser recognizer, NoViableAltException e)
   at Antlr4.Runtime.DefaultErrorStrategy.ReportError(Parser recognizer, RecognitionException e)
   at Rubberduck.Parsing.Grammar.VBAParser.mainBlockStmt() in C:\projects\rubberduck\Rubberduck.Parsing\Grammar\VBAParser.cs:line 2039
   at Rubberduck.Parsing.Grammar.VBAParser.blockStmt() in C:\projects\rubberduck\Rubberduck.Parsing\Grammar\VBAParser.cs:line 1632
   at Rubberduck.Parsing.Grammar.VBAParser.block() in C:\projects\rubberduck\Rubberduck.Parsing\Grammar\VBAParser.cs:line 1547
   at Rubberduck.Parsing.Grammar.VBAParser.withStmt() in C:\projects\rubberduck\Rubberduck.Parsing\Grammar\VBAParser.cs:line 12869
   at Rubberduck.Parsing.Grammar.VBAParser.mainBlockStmt() in C:\projects\rubberduck\Rubberduck.Parsing\Grammar\VBAParser.cs:line 1997
   at Rubberduck.Parsing.Grammar.VBAParser.blockStmt() in C:\projects\rubberduck\Rubberduck.Parsing\Grammar\VBAParser.cs:line 1632
   at Rubberduck.Parsing.Grammar.VBAParser.block() in C:\projects\rubberduck\Rubberduck.Parsing\Grammar\VBAParser.cs:line 1547
   at Rubberduck.Parsing.Grammar.VBAParser.ifStmt() in C:\projects\rubberduck\Rubberduck.Parsing\Grammar\VBAParser.cs:line 7799
   at Rubberduck.Parsing.Grammar.VBAParser.mainBlockStmt() in C:\projects\rubberduck\Rubberduck.Parsing\Grammar\VBAParser.cs:line 1871
   at Rubberduck.Parsing.Grammar.VBAParser.blockStmt() in C:\projects\rubberduck\Rubberduck.Parsing\Grammar\VBAParser.cs:line 1632
   at Rubberduck.Parsing.Grammar.VBAParser.block() in C:\projects\rubberduck\Rubberduck.Parsing\Grammar\VBAParser.cs:line 1547
   at Rubberduck.Parsing.Grammar.VBAParser.subStmt() in C:\projects\rubberduck\Rubberduck.Parsing\Grammar\VBAParser.cs:line 11512
   at Rubberduck.Parsing.Grammar.VBAParser.moduleBodyElement() in C:\projects\rubberduck\Rubberduck.Parsing\Grammar\VBAParser.cs:line 1483
   at Rubberduck.Parsing.Grammar.VBAParser.moduleBody() in C:\projects\rubberduck\Rubberduck.Parsing\Grammar\VBAParser.cs:line 1387
   at Rubberduck.Parsing.Grammar.VBAParser.module() in C:\projects\rubberduck\Rubberduck.Parsing\Grammar\VBAParser.cs:line 363
   at Rubberduck.Parsing.Grammar.VBAParser.startRule() in C:\projects\rubberduck\Rubberduck.Parsing\Grammar\VBAParser.cs:line 266
   at Rubberduck.Parsing.VBA.VBAModuleParser.Parse(String moduleName, CommonTokenStream moduleTokens, IParseTreeListener[] listeners, BaseErrorListener errorListener, ITokenStream& outStream) in C:\projects\rubberduck\Rubberduck.Parsing\VBA\VBAModuleParser.cs:line 31
   at Rubberduck.Parsing.VBA.AttributeParser.Parse(IVBComponent component, CancellationToken token, ITokenStream& stream, IParseTree& tree) in C:\projects\rubberduck\Rubberduck.Parsing\VBA\AttributeParser.cs:line 66
   at Rubberduck.Parsing.VBA.ComponentParseTask.RunAttributesPass(CancellationToken token, IParseTree& attributesTree, IDictionary`2& attributes) in C:\projects\rubberduck\Rubberduck.Parsing\VBA\ComponentParseTask.cs:line 136
   at Rubberduck.Parsing.VBA.ComponentParseTask.Start(CancellationToken token) in C:\projects\rubberduck\Rubberduck.Parsing\VBA\ComponentParseTask.cs:line 54

What's on or around this?

2017-07-18 16:43:12.9507;WARN-2.0.14.29721;Rubberduck.Parsing.VBA.ComponentParseTask;Syntax error; offending token ',' at line 106, column 48 in module Quarterly Report.LoadData.;

line 106, column 48 in module Quarterly Report.LoadData.

MDoerner commented 7 years ago

I see the problem and could reproduce it. (The exception handler had a larger portion of the code.)

MCVE

Public Sub Test()
    Dim x As Long
    x = Foo(1, , 5)
End Sub

Public Function Foo(a, Optional b, Optional c) As Long
    Foo = 42
End Function

The problem seems to be that there has been some change around argumentExpression and argumentList which makes it impossible to handle empty arguments.

retailcoder commented 7 years ago

Can you repro with 2.1.1986? (God I LOVE this instantaneous release thing)