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

V1Model extern argument constraints #134

Open
hackedy opened this issue May 9, 2020 · 3 comments
Open

V1Model extern argument constraints #134

hackedy opened this issue May 9, 2020 · 3 comments

Comments

@hackedy
Copy link
Collaborator

hackedy commented May 9, 2020

There are a few externs and extern functions with constraints on arguments beyond what is encoded in the type system, and some negative tests are failing because we don't enforce these constraints.

Calls to extract(hdr, n) should require hdr to be variable-width:

  • examples/checker_tests/bad/extract1.p4

extract() only defined for headers:

  • examples/checker_tests/bad/extract.p4
  • examples/checker_tests/bad/issue477.p4

Calls to lookahead<H>() should require H be fixed-width:

  • examples/checker_tests/bad/issue600.p4
  • examples/checker_tests/bad/issue478.p4

The argument to push_front should be a compile-time known number:

  • examples/checker_tests/bad/push_nonconstant.p4

The final argument to hash should be fixed-width:

  • examples/checker_tests/bad/issue584.p4
@hackedy
Copy link
Collaborator Author

hackedy commented May 9, 2020

Registers only allow bit elements: examples/checker_tests/bad/issue1777-bmv2.p4

@hackedy
Copy link
Collaborator Author

hackedy commented Jun 24, 2020

Also in this vein: type argument constraints in v1model.p4.

* M must be a struct.
 *
 * H must be a struct where every one if its members is of type
 * header, header stack, or header_union.

See examples/checker_tests/bad/issue1672-bmv2.p4 for an example.

@hackedy
Copy link
Collaborator Author

hackedy commented Feb 16, 2023

Related: verify() can only be called within parsers. See control-verify.p4.

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

No branches or pull requests

1 participant