comp.lang.ada
 help / color / mirror / Atom feed
From: Nick Foubert <nick@metropolitan.ai>
Subject: Rejected (legal?) program
Date: Fri, 14 Apr 2023 09:10:10 -0700 (PDT)	[thread overview]
Message-ID: <fcc21c0e-4a1e-4d5d-954c-7dc20f045353n@googlegroups.com> (raw)

I raised this in the ada-lang gitter channel and it was suggested that this is likely a bug, but figured I'd post here before raising a bug report just in case.

The following example program gives me a compile error with x86-64 gnat 12.2 (can also be seen at https://ada.godbolt.org/z/45G1x9sEd)

example.adb:70:05: error: instantiation error at line 67
example.adb:70:05: error: "P_Formal_Type" is not a visible entity of "P_Instance"

-----

procedure Example is

    generic
        type E_Formal_Type is 
            abstract tagged private;    
    package E is end;

    type E_Actual_Type is tagged null record;

    package E_Instance is new E (E_Actual_Type);

    generic
        with package E_Formal_Pkg is new E (<>);

        type D_Formal_Type is 
            new E_Formal_Pkg.E_Formal_Type with private;

    package D is end;

    type D_Actual_Type is 
        new E_Actual_Type with null record;

    package D_Instance is 
        new D (E_Instance, D_Actual_Type);

    generic    

        with package E_Formal_Pkg is new E (<>);

        with package D_Formal_Pkg is 
            new D
                (E_Formal_Pkg => E_Formal_Pkg,
                others           => <>);

        type P_Formal_Type is 
            new E_Formal_Pkg.E_Formal_Type with private;
            
    package P is end;

    type P_Actual_Type is 
        new E_Actual_Type with null record;

    package P_Instance is 
        new P (E_Instance, D_Instance, P_Actual_Type);

    generic
        with package E_Formal_Pkg is new E (<>);

        with package D_Formal_Pkg is 
            new D (E_Formal_Pkg => E_Formal_Pkg,
                   others       => <>);

        with package P_Formal_Pkg is 
            new P
                (E_Formal_Pkg => E_Formal_Pkg,
                 D_Formal_Pkg => D_Formal_Pkg,
                 others       => <>);

    package Test is 
        type Test_Type is 
            new P_Formal_Pkg.P_Formal_Type with null record; -- Line 67
    end Test;

    package Test_Instance is -- Line 70
       new Test (E_Instance, D_Instance, P_Instance);
        

begin
    null;
end Example;

---

Per ARM 12.7.10/2 I believe that should be legal? 

A slight modification as can be seen at https://ada.godbolt.org/z/4x4h4s7f5 compiles successfully.


                 reply	other threads:[~2023-04-14 16:10 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed
replies disabled

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