Because the compiler can't figure out what type the RHS has from
var add = (x, y) => x + y;
Any type that supports the +
operator is a candidate and since the type of x and y is not constraint to be of the same type. There's quit a lot of possible +
operators that could be used and therefore the set of possible types for x and y is rather large but to be able to determine the type of add, the compiler need to be able to reduce the set to just one type for x and one for y (not exactly true, it might be that both a base class and a derived class would fit) and still even if the compiler could figure out the type for x and y or that you specified the types to let's say int
you'd still be left with the fact that both
Expression<Func<int,int,int>>
and Func<int,int,int>
are possible types for add
There are multiple options for how to reduce the set of possible types. The compiler could try to look at how add
is used later but doesn't (and potentially couldn't figure the types out even if it did)