!standard 7.5(2.1/3) 15-10-06 AI12-0172-1/01 !class binding interpretation 15-10-05 !status Amendment 1-2012 16-02-29 !status WG9 Approved 16-06-13 !status ARG Approved 8-0-0 15-10-16 !status work item 15-10-05 !status received 15-08-24 !priority Low !difficulty Easy !qualifier Omission !subject Raise expressions in limited contexts !summary Raise expressions are allowed in limited contexts. !question 7.5(2.1/3) says: In the following contexts, an expression of a limited type is not permitted unless it is an aggregate, a function_call, a parenthesized expression or qualified_expression whose operand is permitted by this rule, or a conditional_expression all of whose dependent_expressions are permitted by this rule: As written, this does not allow a raise_expression in these contexts (since a raise expression matches any type, it has the type it matches, thus these raise expressions have a limited type). That means that the following are illegal (assuming Lim is a limited record type): Obj : Lim := (raise TBD_Error); function Foo (Bar : in Boolean) return Lim is (if Bar then (null record) else raise Program_Error); Ptr : access Lim := new Lim'(case Glarp is when 1 => (null record); when 2 => Foo (True); when others => (raise Program_Error)); These all seem reasonable, and harmless (no object gets created when the exception is raised). Should these be allowed? (Yes.) !recommendation (See Summary.) !wording Modify 7.5(2.1/3): In the following contexts, an expression of a limited type is not permitted unless it is an aggregate, a function_call, {a raise_expression,} a parenthesized expression or qualified_expression whose operand is permitted by this rule, or a conditional_expression all of whose dependent_expressions are permitted by this rule: !discussion This looks like a pure omission: no one thought about whether it made sense to allow raise expressions in limited contexts. !corrigendum 7.5(2.1/3) @drepl In the following contexts, an @fa of a limited type is not permitted unless it is an @fa, a @fa, a parenthesized @fa or @fa whose operand is permitted by this rule, or a @fa all of whose @i@fas are permitted by this rule: @dby In the following contexts, an @fa of a limited type is not permitted unless it is an @fa, a @fa, a @fa, a parenthesized @fa or @fa whose operand is permitted by this rule, or a @fa all of whose @i@fas are permitted by this rule: !ASIS No ASIS effect. !ACATS test Tests should be constructed for this, based on the existing B750Axx tests. !appendix From: Randy Brukardt Sent: Monday, August 24, 2015 5:52 PM I was looking at the Ada 2012 extensions to the limited context rules. I was wondering where raise expressions fit in. Specifically, 7.5(2.1/3) says: In the following contexts, an expression of a limited type is not permitted unless it is an aggregate, a function_call, a parenthesized expression or qualified_expression whose operand is permitted by this rule, or a conditional_expression all of whose dependent_expressions are permitted by this rule: As written, this does not allow a raise_expression in these contexts (since a raise expression matches any type, it has the type it matches, thus these raise expressions have a limited type). That means that the following are illegal (assuming Lim is a limited record type): Obj : Lim := (raise TBD_Error); function Foo (Bar : in Boolean) return Lim is (if Bar then (null record) else raise Program_Error); Ptr : access Lim := new Lim'(case Glarp is when 1 => (null record); when 2 => Foo (True); when others => (raise Program_Error)); These all seem reasonable to me, and harmless (no object gets created when the exception is raised). I was about to write some tests to check the enforcement of the conditional expression part of 7.5(2.1/3), and I figured I should include raise expressions as well. Except that I probably ought not to, until we discuss this. What does everyone think?? **************************************************************** From: Tucker Taft Sent: Monday, August 24, 2015 8:35 PM > I was about to write some tests to check the enforcement of the > conditional expression part of 7.5(2.1/3), and I figured I should > include raise expressions as well. Except that I probably ought not > to, until we discuss this. What does everyone think?? I agree, this appears to be an oversight, and raise expressions should be permitted. ****************************************************************