oxidecomputer / oxidecomputer/p4

Global `const` symbols not resolved within action/parser bodies

Open
#31 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug front-end
Dominant language
Rust
Stars
137
Forks
12
Avg merge
4d 22h
Merged PRs (30d)
3

Description

const symbols defined in the global scope do not seem to be usable for reads/writes within parser bodies or actions, as below:

const bit<16> GENEVE_OPT_CLASS_OXIDE = 16w0x0129;

control x (
    /* ... */
) {
    action y (
        inout headers_t hdr,
        /* ... */
    ) {
        hdr.ox_external_tag.class = GENEVE_OPT_CLASS_OXIDE;
    }

    /* ... */
}

This produces the following error message:

error: could not resolve lvalue: GENEVE_OPT_CLASS_OXIDE
    GENEVE_OPT_CLASS_OXIDE not found
[361:37] sidecar-lite.p4

          hdr.ox_external_tag.class = GENEVE_OPT_CLASS_OXIDE;
                                      ^^^^^^^^^^^^^^^^^^^^^^

From my testing, this also applies to use of constants within expressions in parser states.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the P4 example with the global const used in an action, then check the corresponding parser-state expression case. Trace name resolution for reads and writes from parser bodies and actions; done means both uses resolve without the reported lvalue error.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.