j3-fortran / generics

BSD 3-Clause "New" or "Revised" License
38 stars 8 forks source link

Add 'except when used as an <instantiation-arg>' #127

Closed aury6623 closed 3 months ago

aury6623 commented 4 months ago

Currently this is our syntax for instantiation-arg:

<instantiation-arg> <<is>> <constant-expr>
                    <<or>> <type-spec>
                    <<or>> <generic-spec>
                    <<or>> <procedure-name>

This PR considers the case where \<type-spec> is used. Here is the definition of \<type-spec>, plus its constraint:

R702 <type-spec> <<is>> <intrinsic-type-spec>
                 <<or>> <derived-type-spec>
                 <<or>> <enum-type-spec>
                 <<or>> <enumeration-type-spec>

C703 (R702) The <derived-type-spec> shall not specify an abstract type (7.5.7).

We want to allow an \<instantiation-arg> to be an abstract derived type. For example:

type, abstract :: my_t
    ...
end type
instantiate tmpl{my_t}

In this example, \<instantiation-arg> is a \<type-spec> which is a \<derived-type-spec>. And so the constraint applies, which is not what we want.

We could fix this by using something else than \<type-spec>, but the simplest solution that I see is to add an exception to the constraint.

everythingfunctional commented 3 months ago

Adressed as #131