comp.lang.ada
 help / color / mirror / Atom feed
From: digitig <digitig@gmail.com>
Subject: Can't work out how to use with Ada.Numerics.Discrete_Random with SPARK 2014
Date: Thu, 29 Jun 2017 18:15:53 -0700 (PDT)
Date: 2017-06-29T18:15:53-07:00	[thread overview]
Message-ID: <e3a88437-89a9-4feb-9780-1b06ca32e033@googlegroups.com> (raw)

In main.ads I have:

package Main
with SPARK_Mode => On
is
   procedure Test;
end Main;

In main.adb I have:

with Ada.Numerics.Discrete_Random;
with Ada.Text_IO;
package body Main
with SPARK_Mode => On
is
   procedure Test is
      subtype Die is Integer range 1 .. 6;
      subtype Dice is Integer range 2*Die'First .. 2*Die'Last;
      package Random_Die is new Ada.Numerics.Discrete_Random (Die);
      use Random_Die;
      G : Generator;
      D : Dice;
   begin
      Reset (G);  -- Start the generator in a unique state in each run
      loop
         -- Roll a pair of dice; sum and process the results
         D := Random(G) + Random(G);
         Ada.Text_IO.Put_Line(D'Image);
      end loop;
   end Test;
end Main;

Running SPARK | Examine all sources from GPS gives me the error:

        9:7 "Random_Die" is not a library-level package
        9:7 incorrect placement of aspect "Spark_Mode"
        9:7 instantiation error at a-nudira.ads:45

Line 9 is:

      package Random_Die is new Ada.Numerics.Discrete_Random (Die);

But the error points into a line in the GNAT library, in a-nudira.ads that simply says

        SPARK_Mode => Off

I'm completely bewildered here - what's wrong with my code here (other than it being a toy example)? And how *do* I use Ada.Numerics.Discrete_Random in conjunction with SPARK?

             reply	other threads:[~2017-06-30  1:15 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-30  1:15 digitig [this message]
2017-06-30  7:28 ` Can't work out how to use with Ada.Numerics.Discrete_Random with SPARK 2014 Simon Wright
2017-06-30 11:38   ` digitig
replies disabled

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