p4c
p4c copied to clipboard
instantation of parser inside functions error message could be clear
Take:
parser p() {
state start {
transition accept;
}
}
void func()
{
p() t;
t();
}
The reference compiler produces:
t8.p4(9): [--Werror=invalid] error: t: cannot instantiate at top-level
p() t;
^
But a function is not the top-level.
Note a similar issue dealing with direct application to the type too:
t8.p4(9): [--Werror=not-found] error: p_inst: declaration not found
p.apply();
^^^^^^^^^
It is not obvious what is wrong from the error message really.
The table in "Appendix: Restrictions on compile time and run time calls" does make it clear this is invalid code but the error message should be improved.
I expect #3279 will fix this one too.
@apinski-cavium Do you consider this issue fixed after #3279 was merged? If yes, please consider closing the issue.