Sorry, you canβt. Whenever you declare a modular type, the module must be a static value, i.e. A value that the compiler can immediately determine there. And it does not work. This applies to many parts of type declarations, especially those parts that the compiler needs to figure out how many bits an object needs, or other functions that represent the object. In Int_Thing, on the other hand, the upper bound of the range does not have to be static (the compiler already knows that Int_Thing will be displayed just like Integer, and the range is used to check the bounds, but it is not used to determine how large Int_Thing will be).
If this is a real situation, and you need a generic type that can handle various modular types, you can make the modular type itself a generic parameter:
generic type Mod_Thing is mod <>; package Modular_Gen_Issue is ...
(PS The range of Mod_Thing in your example will be 0..Max-1, not 0..Max.)
ajb
source share