-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Closed
Description
This code fails with an assert in CheckValEscape. Looks like switch expressions are not handled.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
class Program
{
public enum Rainbow
{
Red,
Orange,
Yellow,
Blue,
Indigo,
Violet
}
public ref struct RGBColor
{
int _r, _g, _b;
public int R => _r;
public int G => _g;
public int B => _b;
public RGBColor(int r, int g, int b)
{
_r = r;
_g = g;
_b = b;
}
}
static void Main(string[] args)
{
// FromRainbow(Rainbow.Red);
}
public static RGBColor FromRainbow(Rainbow colorBand) =>
colorBand switch
{
Rainbow.Red => new RGBColor(0xFF, 0x00, 0x00),
Rainbow.Orange => new RGBColor(0xFF, 0x7F, 0x00),
Rainbow.Yellow => new RGBColor(0xFF, 0xFF, 0x00),
Rainbow.Blue => new RGBColor(0x00, 0x00, 0xFF),
Rainbow.Indigo => new RGBColor(0x4B, 0x00, 0x82),
Rainbow.Violet => new RGBColor(0x94, 0x00, 0xD3),
_ => throw null!
};
}Reactions are currently unavailable