Skip to content

Commit 7d4431c

Browse files
committed
fix RuntimeBinderException with optional object parameters (resolver bug)
1 parent 3249f95 commit 7d4431c

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

Rubberduck.Parsing/Binding/BindingService.cs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
using Antlr4.Runtime;
1+
using System.Diagnostics;
2+
using Antlr4.Runtime;
3+
using Rubberduck.Parsing.Grammar;
24
using Rubberduck.Parsing.Symbols;
35

46
namespace Rubberduck.Parsing.Binding
@@ -39,7 +41,13 @@ public IBoundExpression ResolveDefault(Declaration module, Declaration parent, P
3941

4042
public IBoundExpression ResolveType(Declaration module, Declaration parent, ParserRuleContext expression)
4143
{
42-
return _typedBindingContext.Resolve(module, parent, expression, null, StatementResolutionContext.Undefined);
44+
var context = expression;
45+
var opContext = expression as VBAParser.RelationalOpContext;
46+
if (opContext != null && opContext.Parent is VBAParser.ComplexTypeContext)
47+
{
48+
context = opContext.GetChild<VBAParser.LExprContext>(0);
49+
}
50+
return _typedBindingContext.Resolve(module, parent, context, null, StatementResolutionContext.Undefined);
4351
}
4452

4553
public IBoundExpression ResolveProcedurePointer(Declaration module, Declaration parent, ParserRuleContext expression)

Rubberduck.Parsing/Binding/StatementResolutionContext.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ public enum StatementResolutionContext
44
{
55
Undefined,
66
SetStatement,
7-
LetStatement
7+
LetStatement,
8+
DefaultParamValue,
89
}
910
}

0 commit comments

Comments
 (0)