-
-
Couldn't load subscription status.
- Fork 91
Closed
Milestone
Description
Sample C# Code
public class Variable
{
public string Name { get; set; }
public Variable(string name)
{
Name = name;
}
}
Func<Variable, string, Variable> fx = (input, text) => {
input = input ?? new Variable("default");
input.Value = text;
return input;
};Test Case
public class Variable
{
public string Name { get; set; }
public Variable(string name)
{
Name = name;
}
}
[Test]
public void CoalescFail()
{
var input = Parameter(typeof(Variable));
var text = Parameter(typeof(string));
var ctor = typeof(Variable).GetConstructor(new Type[] { typeof(string) });
var property = typeof(Variable).GetProperty(nameof(Variable.Name));
var lambda = Lambda(
Block(
Coalesce(input, New(ctor, Constant("default"))),
Assign(Property(input, property), text),
input), input, text);
var t = lambda.ToExpressionString();
var fx = lambda.CompileFast<Func<Variable, string,Variable>>();
Assert.NotNull(fx(null, "a"));
}It seems any statement after coalesc is failing.
If you look at this link, coalesc is done without loading null on to the stack. This could be improvement.