Closed
Description
When I run an expression casting a long
to a Nullable<int>
, I get "System.NullReferenceException : Object reference not set to an instance of an object. at (ArrayClosure)"
Here is a sample test, I can take a better look tomorrow and move it to a branch.
[Test]
public void Original_case()
{
var x = Parameter(typeof(int?), "x");
var expr = Lambda<Func<int?>>(
Block(
[x],
Assign(x, TypeAs(Constant(12345L), typeof(int?)))
)
);
expr.PrintCSharp();
var fs = expr.CompileSys();
fs.PrintIL();
var sr = fs();
Asserts.AreEqual(null, sr);
var ff = expr.CompileFast(false);
ff.PrintIL();
var fr = ff();
Asserts.AreEqual(null, fr);
}