I expected the following code to throw a constraint error on compilation, however it didn't. It also does not throw a runtime error on the c2 assignment. Edit: Running the compiler with -gnata solves the compilation warning issue, but does not solve the lack-of runtime error issue. It is compiled using GNAT FSF with no optimizations, just: gnatmake main Edit: gnatmake -gnata main
with Ada.Text_IO; use Ada.Text_IO;
procedure Main is
subtype cat is Integer with Dynamic_Predicate => cat in 1 .. 9;
c1 : cat;
c2 : cat;
begin
c1 := 5;
c2 := 99;
end Main;
I thought that the Dynamic_Predicate line would essentially be equivalent to the following :
subtype cat is Integer range 1 .. 9;