Input code
A return null; statement inside a lambda whose return type is inferred to an anonymous type. Minimal repro:
using System;
class Repro
{
static bool Cond;
static T Infer<T>(Func<T> factory) => factory(); // T is inferred to the anonymous type
public object Trigger()
{
return Infer(() =>
{
if (Cond)
{
Console.WriteLine();
return null;
}
return new { Value = 1 };
});
}
}
Erroneous output
public object Trigger()
{
return Infer(delegate
{
if (Cond)
{
Console.WriteLine(); // prevent ternary
return (<>f__AnonymousType0<int>)null;
}
return new { Value = 1 };
});
}
return (<>f__AnonymousType0<int>)null; does not recompile — <>f__AnonymousType0 is not a referenceable identifier:
error CS1525: Invalid expression term '<'
Details
- Product in use: ICSharpCode.Decompiler (via ilspycmd)
- Version in use: 10.1.0.8388, built from master (
ddbb24f24)
Input code
A
return null;statement inside a lambda whose return type is inferred to an anonymous type. Minimal repro:Erroneous output
return (<>f__AnonymousType0<int>)null;does not recompile —<>f__AnonymousType0is not a referenceable identifier:Details
ddbb24f24)