Version 1.1 of ai12s/ai12-0172-1.txt

Unformatted version of ai12s/ai12-0172-1.txt version 1.1
Other versions for file ai12s/ai12-0172-1.txt

!standard 7.5(2.1/3)          15-10-06 AI05-0172-1/01
!class binding interpretation 15-10-05
!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.
!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.

****************************************************************

Questions? Ask the ACAA Technical Agent