protected internal override void CheckSemantics(AstHelper astHelper)
        {
            FunctionName.CheckSemantics(astHelper);

            foreach (Expression expression in Parameters)
            {
                expression.CheckSemantics(astHelper);
            }
            Type[] parameterTypes = Parameters.Select(param => param.Type).ToArray();

            if (!astHelper.Errors.Check(new FunctionNotDefinedError(FunctionName.Name, parameterTypes,
                                                                    astHelper.Functions, Start)))
            {
                FunctionReference functionReference = astHelper.Functions[FunctionName.Name, parameterTypes];

                _type    = functionReference.ReturnType;
                _pointer = functionReference.Function;
            }
            else
            {
                // if there is any error
                _type    = typeof(Null);
                _pointer = MAst.Empty();
            }
        }
        protected internal override void CheckSemantics(AstHelper astHelper)
        {
            FunctionName.CheckSemantics(astHelper);

            // initialize the scopes for each one of the arguments
            var scopes = new AstHelper[Args.Count()];

            for (int i = 0; i < scopes.Length; scopes[i++] = astHelper.CreateChild(expecting: true))
            {
            }

            foreach (var item in Args.Zip(scopes, (arg, scope) => new { arg, scope }))
            {
                item.arg.CheckSemantics(item.scope);
            }

            Type[] argTypes = (from arg in Args select arg.Type).ToArray();

            if (astHelper.Errors.Check(new FunctionNotDefinedError(FunctionName.Name, argTypes, astHelper.Functions,
                                                                   Start)))
            {
                return;
            }

            _pointer = astHelper.Functions[FunctionName.Name, argTypes];

            // SPEC: The following are legal: function f(p:rec) = f(nil)
            // for that reason the expected type for each one of the arguments is the
            // type of the function argument (in the definition)
            foreach (var item in _pointer.ArgTypes.Zip(scopes, (type, scope) => new { type, scope }))
            {
                item.scope.Expecting.Type = item.type;
            }
        }