comp.lang.ada
 help / color / mirror / Atom feed
* use type does not seem to work for types in generic package instantiations
@ 2020-02-18  1:37 yoehoduv
  2020-02-18  4:19 ` yoehoduv
  0 siblings, 1 reply; 2+ messages in thread
From: yoehoduv @ 2020-02-18  1:37 UTC (permalink / raw)


It looks like use type has no effect when the type is from a package
declared in the same region as the use type statement.

I can make the primitive subprograms of a type directly visible with
`use all type` like this:

     package Type_Package is
        type T is null record;
        procedure Action(X: T) is null;
     end Type_Package;

     with Type_Package;
     procedure Use_Type is
        use all type Type_Package.T;
        X: Type_Package.T;
     begin
        Action(X);
     end Use_Type;

However, it does not seem to work when I move `Type_Package` inside
`Use_Type`.

     procedure Use_Type is
        package Type_Package is
           type T is null record;
           procedure Action(X: T) is null;
        end Type_Package;
        use all type Type_Package.T;
        X: Type_Package.T;
     begin
        Action(X);
     end Use_Type;

I get

     gcc -c use_type.adb
     use_type.adb:9:04: "Action" is not visible
     use_type.adb:9:04: non-visible declaration at line 4
     gnatmake: "use_type.adb" compilation error

The same thing occurs when I instantiate a generic package.  For
example, when I want to use the data types in `Ada.Containers`.

     package Element_Set is
        new Ada.Containers.Hashed_Sets(Element_Type, Hash, "=");
     use all type Element_Set.Set;

The `use type` clause here seems to have no effect.

Does anyone know why?

I originally posted this at
<https://stackoverflow.com/questions/60246613/how-to-use-a-type-from-a-child-package-generic-package-instantiation>

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

* Re: use type does not seem to work for types in generic package instantiations
  2020-02-18  1:37 use type does not seem to work for types in generic package instantiations yoehoduv
@ 2020-02-18  4:19 ` yoehoduv
  0 siblings, 0 replies; 2+ messages in thread
From: yoehoduv @ 2020-02-18  4:19 UTC (permalink / raw)


I checked the Stack Overflow post again.  It has already got an answer. 
It seems to be a compiler bug.


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

end of thread, other threads:[~2020-02-18  4:19 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-02-18  1:37 use type does not seem to work for types in generic package instantiations yoehoduv
2020-02-18  4:19 ` yoehoduv

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