protected internal override void CheckSemantics(AstHelper astHelper) { base.CheckSemantics(astHelper); // todo use a block expression to code this expression, it's better than defining it inside a function string functionName = "#Eval"; _implementation = new LetInExpression { FunctionDefinitions = new List <FunctionDefinitionExpression> { new FunctionDefinitionExpression { Name = new IdentifierNode { Name = functionName }, ReturnTypeName = new TypeReferenceNode(Guards.First().Result.Type), //bug in the guards Body = new ListSemiExpression(from guard in Guards select new IfThenExpression { Test = MatchExpressions(Match, guard.Test), Then = new ReturnExpression { Value = guard.Result } }) { new ThrowExpression { Expression = new NewExpression(typeof(ArgumentOutOfRangeException)) }, new DefaultValueExpression(Guards.First().Result.Type) } } }, Body = new ListSemiExpression { new FunctionInvokeExpression { FunctionName = new IdentifierNode { Name = functionName } } } }; _implementation.CheckSemantics(astHelper); }