You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
controlz<D1, T1>(X<D1> x, inD1v, inT1t)
{
// x's type is X<D1>// x.f's type is T f<T>(D1 d, T t);apply {
T1r1 = x.f<T1>(v, t);
T1r2 = x.f(v, t);
}
}
While the spec clearly says:
Unlike control type declarations, control declarations may not be generic---e.g., the following declaration is illegal:
controlC<H>(inoutHdata) { /* Body omitted */ }
However, no diagnostics is ever produced. Because control is unused?
generic.p4(17): [--Wwarn=unused] warning: 'T' is unused
extern Crc16<T>
^
generic.p4(27): [--Wwarn=unused] warning: Control q is not used; removing
control q<S>(in S dt)
^
generic.p4(41): [--Wwarn=unused] warning: Control z is not used; removing
control z<D1, T1>(X<D1> x, in D1 v, in T1 t)
^
[--Wwarn=missing] warning: Program does not contain a `main' module
The text was updated successfully, but these errors were encountered:
fruffy
added
p4-spec
Topics related to the P4 specification (https://github.com/p4lang/p4-spec/).
question
This is a topic requesting clarification.
labels
Mar 11, 2025
Note that the commit history for test program generic.p4 goes back to 2016 with Mihai Budiu. It has been somewhat common that in a few areas, p4c has had experimental extensions that went beyond the language specification.
That said, I do not know the detailed history of proposals for supporting generics in more or fewer places in the P4 language, as I have never personally used them for anything, nor thought deeply about the implications on the language.
@jafingerhut Yeah. The problem is that while it might be an extension, no diagnostics is currently produced. So user might write such code by accident and not realize that this is something now well supported.
generic.p4 test contains the following:
While the spec clearly says:
However, no diagnostics is ever produced. Because control is unused?
The text was updated successfully, but these errors were encountered: