I encountered this error when compiling the program
“[–Werror=invalid] error: MyIngress.packet_route: Invalid Program can not be implemented on this taret since it contains a path from table MyIngress.packet_route back to itself
table packet_route{
^^^^^^^^^^^^
Compilation Error”
To be fair, this seems to be more of an issue related to a target limitation than a P4 issue itself. As mentioned in the thread, some targets might allow multiple reads indeed and some others will not.
You will have to design your code so it executed one or the other.
Yes, there is nothing about the P4 language itself that prevents apply’ing a table more than once per target, but many target devices impose a restriction like this, including the behavioral-model target with the v1model architecture.