DEVELOPMENT EDITION · 769442725406
Diagnostics Reference
On this page

B5113: exceptional case might fail

Catalog status: active. Default severity: error. Stable name: exceptional-case. Family: Contracts and termination.

Exceptional_Cases says, for each exception a procedure may propagate, what holds when it does. Verada proves it on every path that propagates the exception: from a raise in the procedure, or from a call of a procedure that propagates it. Callers rely on the consequence in their handlers, as they rely on the postcondition after a normal return.

Example (Vada)

   procedure Check (X : Integer) with Exceptional_Cases => (Too_Large => X > 100) is
   begin
      if X > 50 then
         raise Too_Large;   --  raised for 51 too
      end if;
   end Check;

Example (Varc)

    fn Check(X: Integer)
        throws { Too_Large => X > 100 }
    {
        if X > 50 {
            throw Too_Large;   // raised for 51 too
        }
    }

What to do

Correct the consequence (here X > 50), or raise only where it holds. The counterexample shows values for which the exception propagates and the consequence is false.

Regression source and further reading

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

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