Skip to content
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: "expected an instance declaration" #92

Closed
jnfoster opened this issue Sep 27, 2016 · 4 comments
Closed

Compiler bug: "expected an instance declaration" #92

jnfoster opened this issue Sep 27, 2016 · 4 comments

Comments

@jnfoster
Copy link
Contributor

The following program

//architecture
parser Parser();
parser MyParser(Parser p);
package Package(MyParser p1, MyParser p2);

//program
parser Parser1(Parser p) {
  state start {
   p.apply();
   transition accept;
  }
}

parser Parser2(Parser p) {
  state start {
   p.apply();
   transition accept;
  }
}

Parser1() p1;
Parser2() p2;

Package(p1,p2) main;

crashes with a compiler bug:

terminate called after throwing an instance of 'Util::CompilerBug'
  what():  COMPILER BUG: ../midend/inlining.cpp:255
bug2.p4(6): <Parameter>(33) <Type_Name>(32):Parser p expected an instance declaration
parser Parser1(Parser p) {
               ^^^^^^^^
@jnfoster jnfoster changed the title "expected an instance declaration" Compiler bug: "expected an instance declaration" Sep 27, 2016
@mihaibudiu
Copy link
Contributor

I will change the spec to forbid parsers, controls and packages to be passed as arguments (they can only be passed as constructor arguments). So this program will fail with an error. This should also take care of the problem of the architecture passing parsers as arguments to parsers.

I have checked-in two examples that test passing parsers as arguments, testdata/p4_16_*/parser-arg.p4. The examples and fixes will be part of the next pull request.

@jnfoster
Copy link
Contributor Author

Should global variables whose type is a parser, control, or package also be forbidden?

@mihaibudiu
Copy link
Contributor

main is such a global instance.

@jnfoster
Copy link
Contributor Author

Good point :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants