A subtype indication with an incompatible range is not static AI-00114/06 1 89-06-16 BI WA | !standard 04.09 (11) 89-06-16 AI-00114/06 !class binding interpretation 83-11-07 | !status WG9-approved 89-06-16 !status ARG-approved (reviewed) 88-10-03 !status ARG-approved (discussed) 88-06-07 (pending editorial review) !status ARG-approved (15-0-1) 87-09-15 (pending editorial review) !status panel-approved (5-0-1) 87-09-15 !status work-item 87-04-06 !status received 83-11-07 | !references AI-00409, 83-00166, 83-00934 !topic A subtype indication with an incompatible range is not static !summary 88-05-03 If the range constraint in a subtype indication is not compatible with the type mark, the subtype formed by the subtype indication is not static. !question 88-03-29 4.9(11) says: A static subtype is either a scalar base type, other than a generic formal type; or a scalar subtype formed by imposing on a static subtype either a static range constraint, or a floating or fixed point constraint whose range constraint, if any, is static. 4.9(2) says that a static expression must deliver a value, i.e., if evaluation of the expression raises an exception, the expression is not static. However, there seems to be no corresponding rule for subtype indications. Given a subtype indication whose type mark denotes a static subtype and whose range constraint is also static, can the subtype be considered static even if the compatibility check raises CONSTRAINT_ERROR? This is not just an academic question. For example, since the choices in a variant part must be static (3.7.3(4)), is the following example illegal, or is it legal, raising CONSTRAINT_ERROR? type R (D : NATURAL) is record case D is when POSITIVE range 0 .. 5 => -- legal? (no) I : INTEGER; when others => J : INTEGER; end case; end record; !recommendation 88-05-03 If the range constraint in a subtype indication is not compatible with the type mark, the subtype formed by the subtype indication is not static. A subtype indication with an incompatible range is not static AI-00114/06 2 89-06-16 BI WA !discussion 88-08-08 4.9(11) refers to the subtype formed by imposing a constraint in a subtype indication. It was intended that such a subtype not be considered static if the subtype indication fails to create a subtype. This is the case if the compatibility check associated with the subtype indication raises an exception. Hence it was intended that the example be considered illegal. This treatment of subtypes extends to subtypes formed in generic instances. For example, generic type I is range <>; package GU is subtype S is I range 0 .. 1; end GU; with GU; package P is package NU1 is new GU (POSITIVE); -- is NU1.S static? No. package NU2 is new GU (NATURAL); -- is NU2.S static? Yes. end P; Any attempt to use P.NU1.S as a static subtype will be illegal.