chapel-lang / chapel

a Productive Parallel Programming Language
https://chapel-lang.org
Other
1.78k stars 418 forks source link

Generate warning for enum select statements that miss values #10335

Open bradcray opened 6 years ago

bradcray commented 6 years ago

This issue requests that select statements over enums that are incomplete should generate a warning or error:

enum clrs { RED, GREEN, BLUE };
var c = clrs.GREEN;

select c {
  when clrs.RED do writeln("c is RED");
  when clrs.BLUE do writeln("c is BLUE");
  // compilation warning expected: GREEN not handled
}

[converting to an issue as part of #9222]

In test/users/kreider/feature_select.chpl (#2060), @PriMachVisSys requested a compiler warning for select statements over enums that do not have cases for each of the enum's values. I'm capturing this as an issue here as part of my effort w.r.t. #9222.

ronawho commented 6 years ago

Thematically related to https://github.com/chapel-lang/chapel/issues/10192 (don't error about missing returns for exhaustive select stmts)

For both issues I imagine the underlying analysis will be the same.

bradcray commented 6 years ago

Thanks, I meant to link them, but then forgot by the time I'd written it up (I was disappointed to find that the .future and your issue differed since it meant I had to write this up :) ).