-
Notifications
You must be signed in to change notification settings - Fork 445
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Using enum as a type generates syntax error. #492
Comments
You see what a terrible error message this is from gtest, it does not really tell you where the error is. I cannot reproduce this error, I am getting the following:
|
What do you mean "from GTest"? That's just p4c's normal error reporting. The line that's being reported is correct. |
|
Yes, that is correct. That error message points to the line where the error is in the P4 program, which is also a line in a |
Yes, but I don't have that C++ program, since the code is not checked-in. |
Mihai, I am on 482a3bd. I see this error message for Han's original code snippet, which is like yours but also dumps core:
With the newer code since he updated the issue, I see the kind of error he first reported:
|
I don't understand where this error is coming from. Look at the code, there is no line like the one quoted in the sources. There is no identifier |
He updated the code to
|
@jnfoster: the compiler is dumping core because you can't compile this with p4c-bm2-ss; this is not a program for v1model. |
I pasted the wrong test case in the original email. Thanks Nate for pointing that out. |
This example is not syntactically correct; you can only use types as type arguments when specializing a type. However, HashAlgo.CRC32 is not a type, it is a constant. |
However, @hanw's example is using HashAlgo as the the type, and HashAlgo.CRC32 as a constant parameter. That doesn't work either. |
The example posted won't work in Java or C# either; the generics in P4 are modeled after those languages. |
Here is the source for all the examples that @hanw is trying to get through the compiler: https://github.com/cc10512/p4c/blob/cc/psa/p4include/psa.p4 |
There are generic externs in v1model.p4. In particular, register is a working example. |
Can we safely close this? |
Closed by passing constant value as a constructor parameter. |
Issue:
action_selector does not accept an enum as the type for instantiation.
Error message:
The text was updated successfully, but these errors were encountered: