Skip to content

Commit 6a84c09

Browse files
committed
added resolver test for SubscriptWrite with object (non-array) variable
1 parent 0f42c9c commit 6a84c09

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

RubberduckTests/Grammar/ResolverTests.cs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -902,6 +902,30 @@ End Sub
902902
&& !item.IsAssignment));
903903
}
904904

905+
[TestMethod]
906+
public void SubscriptWrite_IsNotAssignmentReferenceToObjectDeclaration()
907+
{
908+
var code = @"
909+
Public Sub DoSomething()
910+
Dim foo As Object
911+
Set foo = CreateObject(""Scripting.Dictionary"")
912+
foo(""key"") = 42
913+
End Sub
914+
";
915+
// act
916+
var state = Resolve(code);
917+
918+
// assert
919+
var declaration = state.AllUserDeclarations.Single(item =>
920+
item.DeclarationType == DeclarationType.Variable
921+
&& item.IdentifierName == "foo");
922+
923+
Assert.IsNotNull(declaration.References.SingleOrDefault(item =>
924+
item.ParentScoping.DeclarationType == DeclarationType.Procedure
925+
&& item.ParentScoping.IdentifierName == "DoSomething"
926+
&& !item.IsAssignment));
927+
}
928+
905929
[TestMethod]
906930
public void ArraySubscriptWrite_IsAssignmentReferenceToArrayDeclaration()
907931
{

0 commit comments

Comments
 (0)