Subtypes are not visible when limited with'd?

Is this normal?

The compiler kept telling me that LR_Axes was not in the package I was referencing, when it was.

So, I changed it to a type and it stopped complaining. WTAF?

This is in the spec, not the body which has a full view of the package.

The source is:

with SDL.Inputs.Joysticks.Events;
limited with SDL.Inputs.Joysticks.Game_Controllers.Events;

package SDL.Inputs.Joysticks.Game_Controllers is
   pragma Preelaborate;

...

   function Axis_Value (Self : in Game_Controller;
                        Axis : in Events.LR_Axes)
                       return Events.LR_Axes_Values;

...
end SDL.Inputs.Joysticks.Game_Controllers;

with Interfaces.C.Strings;
with SDL.Error;
with SDL.RWops;
with SDL.Inputs.Joysticks.Game_Controllers.Events;

package body SDL.Inputs.Joysticks.Game_Controllers is
...
   function Axis_Value (Self : in Game_Controller;
                        Axis : in Events.LR_Axes)
                       return Events.LR_Axes_Values is

      function SDL_Game_Controller_Get_Axis (Controller : in SDL.C_Pointers.Game_Controller_Pointer;
                                             Axis       : in Events.LR_Axes)
                                            return Events.LR_Axes_Values with
        Import        => True,
        Convention    => C,
        External_Name => "SDL_GameControllerGetAxis";
   begin
      return SDL_Game_Controller_Get_Axis (Self.Internal, Axis);
   end Axis_Value;
...
end SDL.Inputs.Joysticks.Game_Controllers;

package SDL.Inputs.Joysticks.Game_Controllers.Events is
   pragma Preelaborate;

   type Axes is (Invalid,
                 Left_X,
                 Left_Y,
                 Right_X,
                 Right_Y,
                 Trigger_Left,
                 Trigger_Right) with
     Convention => C;

   for Axes use (Invalid       => -1,
                 Left_X        =>  0,
                 Left_Y        =>  1,
                 Right_X       =>  2,
                 Right_Y       =>  3,
                 Trigger_Left  =>  4,
                 Trigger_Right =>  5);

   subtype LR_Axes      is Axes range Left_X .. Right_Y;
   subtype Trigger_Axes is Axes range Trigger_Left .. Trigger_Right;

...
end SDL.Inputs.Joysticks.Game_Controllers.Events;

and the build errors:

   [Ada]          sdl-inputs-joysticks-game_controllers-events.adb
sdl-inputs-joysticks-game_controllers.ads:60:41: error: "LR_Axes" not declared in "Events"
sdl-inputs-joysticks-game_controllers.ads:64:41: error: "Trigger_Axes" not declared in "Events"
sdl-inputs-joysticks-game_controllers.adb:65:13: error: not type conformant with declaration at sdl-inputs-joysticks-game_controllers.ads:59
sdl-inputs-joysticks-game_controllers.adb:65:13: error: return type does not match
sdl-inputs-joysticks-game_controllers.ads:60:41: error: "LR_Axes" not declared in "Events"
sdl-inputs-joysticks-game_controllers.ads:64:41: error: "Trigger_Axes" not declared in "Events"

   compilation of sdl-inputs-joysticks-game_controllers-events.adb failed
   compilation of sdl-inputs-joysticks-game_controllers.adb failed

No, package limited view doesn’t include subtypes :person_shrugging:

Well, that’s annoying and short sighted.

Well, guessing, subtype has no incomplete view. They break out of separation interface and implementation. So you need the whole to chip something away. Theoretically one could classify constraints into view and implementation ones. Then subtypes constraining only the view could made visible.

Why do you need limited with? It is a crying wolf from the design point of view.

I need it to compile otherwise you get cyclic errors.

I mean that if you need that you might wish to review the design. Circular dependencies are like gotos, a big no-no.

I’m trying to rearrange the events packages, I’m making them children of the sdl.input.* packages they relate to, apart from window stuff which is a child of that. Then I’ll be cleaning up the entire lot, so it’s likely those dependencies should go away.