comp.lang.ada
 help / color / mirror / Atom feed
* SPARK: missing case value
@ 2015-10-09 11:38 Maciej Sobczak
  2015-10-09 12:28 ` Stefan.Lucks
                   ` (2 more replies)
  0 siblings, 3 replies; 17+ messages in thread
From: Maciej Sobczak @ 2015-10-09 11:38 UTC (permalink / raw)


Consider:

   type Enum is (A, B, C);

   procedure Test (E : in Enum)
      with Pre => E /= C
   is
   begin
      case E is
         when A => null;
         when B => null;
      end case;
   end Test;

The Pre contract says that C is never used as a value for E. Still, GNATProve complains about missing case value C in the case statement. The compiler complains, too.

An appropriate subtype (subtype SEnum is Enum range A .. B) can solve this, but it shows some asymmetry between subtypes and contracts, where I would expect that the same subsetting effect can be achieved in both ways. Apparently (and according to AARM), the case statement does not take contracts into account, but my understanding of the rules is that it would not be against the spirit of "covering values that satisfy the predicate".

On the other hand, SPARK is supposed to be a subset of Ada, so even if the above is feasible from the SPARK point of view, it should compile as regular Ada as well and compilers are not required to do this level of static analysis. So, SPARK does not do it, because Ada might not be able to keep the pace.

What are your thoughts on this?

-- 
Maciej Sobczak * http://www.inspirel.com


^ permalink raw reply	[flat|nested] 17+ messages in thread

end of thread, other threads:[~2015-10-11  9:49 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-10-09 11:38 SPARK: missing case value Maciej Sobczak
2015-10-09 12:28 ` Stefan.Lucks
2015-10-09 12:35 ` Mark Lorenzen
2015-10-09 14:53   ` Bob Duff
2015-10-09 14:39 ` Bob Duff
2015-10-09 15:10   ` Dmitry A. Kazakov
2015-10-09 15:22     ` Bob Duff
2015-10-09 15:34       ` Dmitry A. Kazakov
2015-10-09 16:20     ` G.B.
2015-10-09 16:35       ` Dmitry A. Kazakov
2015-10-09 20:29         ` Georg Bauhaus
2015-10-09 21:01           ` Dmitry A. Kazakov
2015-10-10  6:44             ` Randy Brukardt
2015-10-10  9:10             ` Georg Bauhaus
2015-10-10 10:00               ` Dmitry A. Kazakov
2015-10-10 14:19                 ` Georg Bauhaus
2015-10-11  9:49                   ` Dmitry A. Kazakov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox