Skip to content

Commit

Permalink
add test and symptomatic fix for jagged arrray resolution
Browse files Browse the repository at this point in the history
  • Loading branch information
Vogel612 committed Nov 15, 2017
1 parent cca487c commit 649fc72
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Rubberduck.Parsing/Binding/IndexDefaultBinding.cs
Expand Up @@ -127,7 +127,7 @@ private IBoundExpression ResolveLExpressionIsVariablePropertyFunctionNoParameter
bool isVariable = lExpression.Classification == ExpressionClassification.Variable;
bool propertyWithParameters = lExpression.Classification == ExpressionClassification.Property && !((IParameterizedDeclaration)lExpression.ReferencedDeclaration).Parameters.Any();
bool functionWithParameters = lExpression.Classification == ExpressionClassification.Function && !((IParameterizedDeclaration)lExpression.ReferencedDeclaration).Parameters.Any();
if (isVariable || ((propertyWithParameters || functionWithParameters) && _argumentList.HasArguments))
if (lExpression.ReferencedDeclaration != null && (isVariable || ((propertyWithParameters || functionWithParameters) && _argumentList.HasArguments)))
{
IBoundExpression boundExpression = null;
var asTypeName = lExpression.ReferencedDeclaration.AsTypeName;
Expand Down
26 changes: 26 additions & 0 deletions RubberduckTests/Grammar/ResolverTests.cs
Expand Up @@ -112,6 +112,32 @@ End Function
}
}

[TestCategory("Resolver")]
[TestMethod]
public void JaggedArrayReference_DoesNotBlowUp()
{
// see https://github.com/rubberduck-vba/Rubberduck/issues/3098
var code = @"Option Explicit
Public Sub Test()
Dim varTemp() As Variant
ReDim varTemp(0)
varTemp(0) = Array(0)
varTemp(0)(0) = Array(0)
Debug.Print varTemp(0)(0)
End Sub
";

using (var state = Resolve(code))
{
var declaration = state.AllUserDeclarations.Single(item => item.DeclarationType == DeclarationType.Variable && item.IdentifierName == "varTemp");
Assert.IsTrue(declaration.IsArray);
}
}

[TestCategory("Resolver")]
[TestMethod]
public void OptionalParameterDefaultConstValue_IsReferenceToDeclaredConst()
Expand Down

0 comments on commit 649fc72

Please sign in to comment.