Example #1
0
 public override void VisitBlock(BlockSyntax block, BindingScope bindingScope)
 {
     foreach (var statement in block.Statements)
     {
         VisitStatement(statement, bindingScope);
         // Each variable declaration establishes a new binding scope
         if (statement is VariableDeclarationStatementSyntax variableDeclaration)
         {
             bindingScope = new VariableBindingScope(bindingScope, variableDeclaration);
         }
     }
 }
Example #2
0
        private static void Check(FunctionDeclarationSyntax function, Diagnostics diagnostics)
        {
            if (function.Body == null)
            {
                return;
            }

            var bindingScope = EmptyBindingScope.Instance;

            foreach (var parameter in function.Parameters)
            {
                bindingScope = new VariableBindingScope(bindingScope, parameter);
            }

            var shadowChecker = new ShadowChecker(function, diagnostics);

            shadowChecker.VisitExpression(function.Body, bindingScope);
        }