B2035: an overriding operation that may propagate an exception the operation it overrides does not list
Catalog status: active. Default severity: error. Stable name: exceptional-cases-widened. Family: Types and constraints.
A dispatching call of a primitive operation, Grow (S) with S of a class-wide type, runs the version of the operation for the tag of S, which may be an overriding one. What the caller is told the call may propagate is what the operation it names lists in its Exceptional_Cases. So an overriding operation may list only exceptions that the operation it overrides lists too (or that its others covers); anything else would leave the caller's handlers and proofs unprepared for it.
An overriding operation also keeps to the consequences the overridden operation gives for the exceptions it lists: each is proved of its body as well as its own.
Example (Vada)
Too_Big, Too_Small : exception;
type Shape is tagged record
Side : Integer range 0 .. 10;
end record;
procedure Grow (S : in out Shape; By : Integer)
with Exceptional_Cases => (Too_Big => True);
type Square is new Shape with null record;
overriding procedure Grow (S : in out Square; By : Integer)
with Exceptional_Cases => (Too_Big | Too_Small => True);What to do (Vada)
List the exception for the overridden operation too, so that dispatching calls of it expect it, or handle it in the overriding operation:
procedure Grow (S : in out Shape; By : Integer)
with Exceptional_Cases => (Too_Big | Too_Small => True);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.