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

Missing implict conversion from serializable enum to underlying type when used as case label #3623

Closed
apinski-cavium opened this issue Oct 25, 2022 · 0 comments
Assignees
Labels
bug This behavior is unintended and should be fixed. fixed This topic is considered to be fixed.

Comments

@apinski-cavium
Copy link

Take:

enum bit<4> e
{
  a = 1
}
control c(in bit<4> v)
{
  apply{
    switch(v) {
      e.a:
      default: {}
    }
  }
}

I would had assumed there was an implict conversion from the serializable enum to the underlying type here (as so many other places do the implict conversion) but p4c rejects this code with the following error message:

testsuite/p4c.language/valid/control/bitswitch-4.p4(8): [--Werror=type-error] error: SwitchStatement: not defined on bit<4> and e
    switch(v) {
    ^^^^^^

Which is not helpful as it does not show the case label on where the problem is located.

@mihaibudiu mihaibudiu self-assigned this Oct 26, 2022
@mihaibudiu mihaibudiu added bug This behavior is unintended and should be fixed. fixed This topic is considered to be fixed. labels Oct 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This behavior is unintended and should be fixed. fixed This topic is considered to be fixed.
Projects
None yet
Development

No branches or pull requests

2 participants