-
-
Notifications
You must be signed in to change notification settings - Fork 91
Closed
Description
Hello,
Your work is amazing, it solves a lot of problems that I couldn't solve. While using it, I found some minor issues with the conversion. Consider the following simple expression:
var p = Expression.Parameter(typeof(uint), "p");
var body = Expression.Convert(p, typeof(float));
var lambda = Expression.Lambda<Func<uint, float>>(body, p);
var func = lambda.Compile();
var fastFunc = lambda.CompileFast();
Console.WriteLine(func(uint.MaxValue));
Console.WriteLine(fastFunc(uint.MaxValue));
It looks like the faster compiled method calculates inconsistent results with the original.
After some investigation, I found that the problem may be in the method EmittingVisitor.TryEmitValueConvert. After carefully reading its logic and doing some Google searching, I found that there is a similar method in the official repository of dotnet, i.e. https://github.com/dotnet/runtime/blob/release/8.0/src/libraries/System.Linq.Expressions/src/System/Linq/Expressions/Compiler/ILGen.cs#L617. I'm not sure if this helps.