Open kevinjwz opened 4 years ago
Interestingly if I wrap the operator+ by some helper function, the program runs without error.
using System;
using System.Linq.Expressions;
class C<T>
{
public static C<T> operator +(C<T> a, C<T> b) => null;
}
class Test
{
static C<T> Add<T>(C<T> a, C<T> b) => a + b;
static void Method<T>()
{
C<T> c=null;
Action action = () => {
Expression<Func<C<T>>> e = () => Add(c, c);
};
action();
}
static void Main(string[] args)
{
Method<int>();
}
}
Version Used: .NET Core 3.1.101 on Windows 10
Steps to Reproduce: Compile and run following code:
Expected Behavior: Either compile and run without errors, or refuse to compile if the program is incorrect.
Actual Behavior: Program compiles without error but throws BadImageFormatException when run.
Test on SharpLab