-
Notifications
You must be signed in to change notification settings - Fork 446
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
Compiler Bug: Null stat #2258
Comments
I've read comments related to this issue on issue #2259 and I understand that it's needed to allow function calls inside table key parameters. |
We have had a few discussions about places where side-effects are forbidden in the language design working group, but we haven't reached consensus. I believe that the current thinking is that we can actually support function calls in key expressions, because the compiler can lift them before the table application. So what is needed is a pass to do this properly. |
This change was approved for adding to the official P4_16 language spec some month ago: https://github.com/p4lang/p4-spec/pull/834/files At least for table key expressions, it explicitly allows side effects, and requires a particular evaluation order. The code transformation shown in that example would be best not to do for all tables, but preferably only for those tables that have at least one key expression with a side effect. e.g. If only @pure and @nosideeffects annotated extern functions are used, or isValid(), then there should not be any need to create temporary variables. |
Using MethodCallExpressions with the function return value as key in tables leads to a compiler bug in the
functionsInlining
pass.function_call_as_key.p4.txt
The text was updated successfully, but these errors were encountered: