@@ -550,44 +550,42 @@ public void Resolve(VBAParser.AsTypeClauseContext context)
550
550
551
551
public void Resolve ( VBAParser . ForNextStmtContext context )
552
552
{
553
+ // In "For expr1 = expr2" the "expr1 = expr2" part is treated as a single expression.
554
+ var assignmentExpr = ( ( VBAParser . RelationalOpContext ) context . expression ( ) [ 0 ] ) ;
555
+ var lExpr = assignmentExpr . expression ( ) [ 0 ] ;
553
556
var firstExpression = _bindingService . ResolveDefault (
554
557
_moduleDeclaration ,
555
558
_currentParent ,
556
- context . expression ( ) [ 0 ] ,
559
+ lExpr ,
557
560
GetInnerMostWithExpression ( ) ,
558
561
StatementResolutionContext . Undefined ) ;
559
- if ( firstExpression . Classification == ExpressionClassification . ResolutionFailed )
560
- {
561
- _boundExpressionVisitor . AddIdentifierReferences (
562
- firstExpression ,
563
- _qualifiedModuleName ,
564
- _currentScope ,
565
- _currentParent ) ;
566
- }
567
- else
562
+ _boundExpressionVisitor . AddIdentifierReferences (
563
+ firstExpression ,
564
+ _qualifiedModuleName ,
565
+ _currentScope ,
566
+ _currentParent ) ;
567
+ if ( firstExpression . Classification != ExpressionClassification . ResolutionFailed )
568
568
{
569
- // In "For expr1 = expr2" the "expr1 = expr2" part is treated as a single expression.
570
- var binOp = ( BinaryOpExpression ) firstExpression ;
571
- var assignmentExpr = binOp . Left ;
572
- var fromExpr = binOp . Right ;
573
569
// each iteration counts as an assignment
574
570
_boundExpressionVisitor . AddIdentifierReferences (
575
- assignmentExpr ,
571
+ firstExpression ,
576
572
_qualifiedModuleName ,
577
573
_currentScope ,
578
574
_currentParent ,
579
575
true ) ;
580
- _boundExpressionVisitor . AddIdentifierReferences (
581
- assignmentExpr ,
582
- _qualifiedModuleName ,
583
- _currentScope ,
584
- _currentParent ) ;
585
- _boundExpressionVisitor . AddIdentifierReferences (
586
- fromExpr ,
587
- _qualifiedModuleName ,
588
- _currentScope ,
589
- _currentParent ) ;
590
576
}
577
+ var rExpr = assignmentExpr . expression ( ) [ 1 ] ;
578
+ var secondExpression = _bindingService . ResolveDefault (
579
+ _moduleDeclaration ,
580
+ _currentParent ,
581
+ rExpr ,
582
+ GetInnerMostWithExpression ( ) ,
583
+ StatementResolutionContext . Undefined ) ;
584
+ _boundExpressionVisitor . AddIdentifierReferences (
585
+ secondExpression ,
586
+ _qualifiedModuleName ,
587
+ _currentScope ,
588
+ _currentParent ) ;
591
589
for ( int exprIndex = 1 ; exprIndex < context . expression ( ) . Count ; exprIndex ++ )
592
590
{
593
591
ResolveDefault ( context . expression ( ) [ exprIndex ] ) ;
0 commit comments