public IExpressionNode Visit(ArrowAnonymFunctionSyntaxNode arrowAnonymFunNode) { if (arrowAnonymFunNode.Definition == null) { throw ErrorFactory.AnonymousFunDefinitionIsMissing(arrowAnonymFunNode); } if (arrowAnonymFunNode.Body == null) { throw ErrorFactory.AnonymousFunBodyIsMissing(arrowAnonymFunNode); } //Anonym fun arguments list var argumentLexNodes = arrowAnonymFunNode.ArgumentsDefinition; //Prepare local variable scope //Capture all outerscope variables var localVariables = new VariableDictionary(_variables.GetAllSources()); var arguments = new VariableSource[argumentLexNodes.Length]; var argIndex = 0; foreach (var arg in argumentLexNodes) { //Convert argument node var varNode = FunArgumentExpressionNode.CreateWith(arg); var source = VariableSource.CreateWithStrictTypeLabel(varNode.Name, varNode.Type, arg.Interval, isOutput: false); //collect argument arguments[argIndex] = source; argIndex++; //add argument to local scope if (!localVariables.TryAdd(source)) { //Check for duplicated arg-names //If outer-scope contains the conflict variable name if (_variables.GetSourceOrNull(varNode.Name) != null) { throw ErrorFactory.AnonymousFunctionArgumentConflictsWithOuterScope(varNode.Name, arrowAnonymFunNode.Interval); } else //else it is duplicated arg name { throw ErrorFactory.AnonymousFunctionArgumentDuplicates(varNode, arrowAnonymFunNode.Definition); } } } var body = arrowAnonymFunNode.Body; return(BuildAnonymousFunction(arrowAnonymFunNode.Interval, body, localVariables, arguments)); }