"missing return statement" despite codepaths covered
enum
type in Vala is not implicitly convertable to/from int
, so when there's a switch-case that covers all possible values of an enum, this means all codepaths are covered. And refusing to compile the code in this case is wrong.
Steps to reproduce (in terms of terminal commands):
$ cat test.vala
public enum Foo {
One, Two
}
public int test(Foo foo) {
switch(foo) {
case One: return 1;
case Two: return 2;
}
}
public void main() {}
$ valac test.vala
Expected
Code successfully compiles.
Actual
test.vala:5.1-5.15: error: missing return statement at end of subroutine body
public int test(Foo foo) {
^^^^^^^^^^^^^^^
Version
valac 0.44.1