p4lang / tutorials

P4 language tutorials
Apache License 2.0
1.33k stars 878 forks source link

enforce priority for tables with optional match_kind key fiels(#455) #570

Closed snapdgn closed 5 months ago

snapdgn commented 5 months ago

Hello, I'm fairly new to p4. This is my attempt to fix #455.

Any feedback or suggestions for improvement would be greatly appreciated. :)

Thanks

jafingerhut commented 5 months ago

Thanks for the PR.

In looking at the existing code, notice that there is a variable match_types_with_priority, which I believe contains all match kinds that, if present in a key, cause the table entry to require a priority. I suspect that a different, probably smaller, change than the one you suggest here would be to add the optional match kind to the set/list/whatever match_types_with_priority. Please investigate an alternate approach like that, to see if you can make it work.

snapdgn commented 5 months ago

I agree, that would indeed be a more concise solution to this. It was an oversight on my part to overlook the already defined assertion error message. I provided a new one, when they more or less convey the same meaning.

I believe just adding the OPTIONAL field to the match_types_with_priority list should suffice in this case (?).

snapdgn commented 5 months ago

hello @jafingerhut , let me know if this looks good, or any further changes are necessary.