What would you stop than from doing something like this:
anonymous F()
{
if (something) return new { a = 5 };
else return new { b = 1, z = "asdf" };
}
How is compiler supposed to know which type is returned then? Should it limit you at design time with error messages that those anonymous types are not the same? Is it worth the effort? You can use dynamic
for such cases or create actual classes if needed - to make code clear.