p4-spec
p4-spec copied to clipboard
Issue #722: Document restrictions on types IH and EH in PSA
Intended to address this issue https://github.com/p4lang/p4-spec/issues/722
Why does section 7.2.7 of p4-16 working doc does not allow header_union as a member of struct?
@hesingh If I go to the working draft of the P4_16 specification here: https://p4.org/p4-spec/docs/P4-16-working-spec.html#sec-type-nesting the first table I see has a row labeled "header_union", and in the column labeled "struct or tuple" the table entry says "allow". Do you see something different, or interpret that somehow as not being allowed?
I see
struct | allowed2 | error | allowed
7.2.7. Type nesting rules
The table below lists all types that may appear as members of headers, header unions, structs, and tuples. Note that int
means an infinite-precision integer, without a width specified.
| | | bit<W> | allowed | error | allowed int<W> | allowed | error | allowed varbit<W> | allowed | error | allowed int | error | error | error void | error | error | error error | error | error | allowed match_kind | error | error | error bool | allowed | error | allowed enum | allowed1 | error | allowed header | error | allowed | allowed header stack | error | error | allowed header_union | error | error | allowed struct | allowed2 | error | allowed tuple | error | error | allowed | | |
Rationale: int
does not have precise storage requirements, un
This row in that table:
struct | allowed2 | error | allowed
means:
struct is allowed as a member in a header (the column heading of the second column), but see footnote 2. it is an error if you attempt to use a struct as a member of a header_union struct is allowed as a member in a struct or tuple
Note something is going on with the draft HTML generation though, see https://github.com/p4lang/p4-spec/issues/1175 . The released spec 1.2.3 is correct.
@jafingerhut Duh, got it, sorry. Your proposal looks fine.