p4-spec icon indicating copy to clipboard operation
p4-spec copied to clipboard

Disallow overloading of parsers, controls, packages

Open mihaibudiu opened this issue 3 years ago • 2 comments

Personnel

  • [x] Owner: @mbudiu-vmw
  • [x] Supporters: @apinski-cavium

Design

  • [x] Document: See below

Implementation

  • [ ] p4-spec:
  • [ ] p4c:

Process

  • [ ] LDWG discussed:
  • [ ] LDWG approved:
  • [ ] Merged into p4-spec:
  • [ ] Merged into p4c:

=======================================

mihaibudiu avatar May 02 '22 20:05 mihaibudiu

See https://github.com/p4lang/p4-spec/pull/1078 Overloading is subtle, since it can be made based on both constructor and apply arguments.

mihaibudiu avatar May 02 '22 21:05 mihaibudiu

Consider this example from @apinski-cavium

Take:
parser p() () {
  state start {
    transition accept;
  }
}
parser p() (bit a) {
  state start {
    transition accept;
  }
}
parser p(bool b) (bit a) {
  state start {
    transition accept;
  }
}
parser p(bool a) () {
  state start {
    transition accept;
  }
}


parser p1() () {
  p() a;
  state start {
    a.apply();
    transition accept;
  }
}

mihaibudiu avatar May 02 '22 21:05 mihaibudiu

Closing as it seems this has been resolved in #1078.

jnfoster avatar Nov 11 '23 13:11 jnfoster