DEVELOPMENT EDITION · 769442725406
Diagnostics Reference
On this page

B2011: case choices do not cover the selector exactly once

Catalog status: active. Default severity: error. Stable name: case-coverage. Family: Types and constraints.

The choices of a case statement or expression must be static and cover every value of the selector's subtype exactly once (Ada RM 5.4), unless a final when others covers the rest.

Example (Vada)

   type Color is (Red, Green, Blue, Yellow);
   ...
   case C is
      when Red => null;
      when Blue => null;     --  Green and Yellow are missing
   end case;

Example (Varc)

    enum Color { Red, Green, Blue, Yellow }
    ...
    match c {
        Red => {}
        Blue => {}     // Green and Yellow are missing
    }

What to do (Vada)

Add the missing choices (for enumerations, listing them keeps the compiler checking when values are added), or add when others. Remove choices covered twice.

What to do (Varc)

Add the missing choices (for enumerations, listing them keeps the compiler checking when values are added), or add a final _ arm. Remove choices covered twice.

Regression source and further reading

Complete regression example: source, command arguments and expected results. The fixture deliberately reproduces this diagnostic.

See types and constraints, the code index, and diagnostic interpretation for modes, replay, fix-its and JSON.