On this page
B4110: tag check might fail
Catalog status: active. Default severity: error. Stable name: tag-check. Family: Executable checks.
A class-wide value (T'Class) may be of T or of any type derived from it. Converting it to one of those types, D (X), is allowed only when its tag says it is of D or of a type derived from D: otherwise it has no D components to see (RM 4.6(42)). The prover found a value of the class whose tag might be of another type.
Example (Vada)
function Width (S : Shape'Class) return Natural is (Rectangle (S).W);
-- S might be a CircleExample (Varc)
fn width(s: Shape::Class) -> Natural = Rectangle(s).w;
// s might be a Circle
What to do (Vada)
Test the tag first (if S in Rectangle'Class then), require it in the precondition (with Pre => S in Rectangle'Class), or make the operation a primitive of the types that have it, so that a dispatching call reaches the right one.
What to do (Varc)
Test the tag first (if s in Rectangle::Class {), require it in the precondition (requires s in Rectangle::Class), or make the operation a primitive of the types that have it, so that a dispatching call reaches the right one.
Regression source and further reading
Complete regression example: source, command arguments and expected results. The fixture deliberately reproduces this diagnostic.
See executable checks, the code index, and diagnostic interpretation for modes, replay, fix-its and JSON.