Section 7.2.8 defines the type nesting rules of P4. But it is not explicitly defined for extern, parser, control, and package types.
How about adding the following to the spec? I marked them as (new).
Element type \ Container type
header
header_union
struct or tuple
list
header stack
bit<W>
allowed
error
allowed
allowed
error
int<W>
allowed
error
allowed
allowed
error
varbit<W>
allowed
error
allowed
allowed
error
int
error
error
error
allowed
error
void
error
error
error
error
error
string
error
error
error
allowed
error
error
error
error
allowed
allowed
error
match_kind
error
error
error
allowed
error
bool
allowed
error
allowed
allowed
error
enumeration types
allowed
error
allowed
allowed
error
header types
error
allowed
allowed
allowed
allowed
header stacks
error
error
allowed
allowed
error
header unions
error
error
allowed
allowed
allowed
struct types
allowed
error
allowed
allowed
error
tuple types
error
error
allowed
allowed
error
list types
error
error
error
allowed
error
(new) extern types
error
error
error
error
error
(new) parser types
error
error
error
error
error
(new) control types
error
error
error
error
error
(new) package types
error
error
error
error
error
And for typedef and type,
Base type B
typedef B <name>
type B <name>
bit<W>
allowed
allowed
int<W>
allowed
allowed
varbit<W>
allowed
error
int
allowed
error
void
error
error
string
allowed
error
error
allowed
error
match_kind
error
error
bool
allowed
allowed
enumeration types
allowed
error
header types
allowed
error
header stacks
allowed
error
header unions
allowed
error
struct types
allowed
error
tuple types
allowed
error
list types
allowed
error
(new) extern types
allowed
error
(new) parser types
allowed
error
(new) control types
allowed
error
(new) package types
allowed
error
a typedef name
allowed
allowed
a type name
allowed
allowed
Allowing typedef for extern, parser, control, and package type is reflected on the following use cases in the p4c compiler test suite. (extern-inst-as-param.p4, issue2735-bmv2.p4, issue2735.p4, and typedef-constructor.p4)
Adding the new entries you describe in those tables looks reasonable to me. Thanks for the links to relevant test cases in the existing p4c test suite.
Section 7.2.8 defines the type nesting rules of P4. But it is not explicitly defined for extern, parser, control, and package types.
How about adding the following to the spec? I marked them as (new).
bit<W>
int<W>
varbit<W>
int
void
string
error
match_kind
bool
And for
typedef
andtype
,typedef B <name>
type B <name>
bit<W>
int<W>
varbit<W>
int
void
string
error
match_kind
bool
typedef
nametype
nameAllowing
typedef
for extern, parser, control, and package type is reflected on the following use cases in the p4c compiler test suite. (extern-inst-as-param.p4, issue2735-bmv2.p4, issue2735.p4, and typedef-constructor.p4)And when those types are aliased, it must be that all the type variables are bound.