veryl
veryl copied to clipboard
`case`/`switch` inconsistent syntax
trafficstars
If you use case/switch as an expression you need to write this:
case a {
0 : 1,
1 : 2,
3..=5 : 4,
10'b00_0000_011x: 5, // matches 6 or 7
default : 6,
};
If you want to use case/switch as a statement you need to write this:
case a {
0: b = 1;
1: b = 2;
2: {
b = 3;
b = 3;
b = 3;
}
default: b = 4;
}
Not only are the cases terminated differently (, vs ;), but also in one case you need the ; in the end, in the other case you don't.
Question: is it really necesarry to distinguish the two cases (expression and statement)? Can't you use the expression syntax for everything? I would favor to do so.