Switch with fall through throws "System.InvalidProgramException: 'Common Language Runtime detected an invalid program.'"
JMPSequeira opened this issue · 2 comments
JMPSequeira commented
Using .NET 5 with the following code:
var param = Expression.Parameter(typeof(int), "p");
var label = Expression.Label(typeof(string));
var switchStatement = Expression.Switch(
typeof(void),
param,
Expression.Return(label, Expression.Constant("bar")),
null,
Expression.SwitchCase(Expression.Return(label, Expression.Constant("foo")),
Expression.Constant(1),
Expression.Constant(2)));
var lambda = Expression.Lambda<Func<int, string>>(
Expression.Block(
switchStatement,
Expression.Label(label, Expression.Constant(string.Empty)))
, param);
var compiled = lambda.Compile();
var res = compiled(1); // "foo"
var compiledFast = lambda.CompileFast();
var resFast = compiledFast(1);
dadhi commented
Thanks for the compact reproduction code. Will check.
dadhi commented
@JMPSequeira The FEC v3.2.1 with the fix is released on NuGet