Skip to content

Commit 75aca49

Browse files
Merge pull request #1363 from kfcripps/1362
[#1362] Clarify that `switch` statements _are_ allowed in action/function bodies, and that `switch` statements with `action_run` expressions are only allowed in control `apply` blocks
2 parents af4dd3d + db5e81d commit 75aca49

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

p4-16/spec/P4-16-spec.adoc

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5463,12 +5463,12 @@ Statements can appear in several places:
54635463

54645464
* Within `parser` states
54655465
* Within a `control` block
5466-
* Within an `action`
5466+
* Within an `action` or function
54675467

54685468
There are restrictions for the kinds of statements that can appear in
5469-
each of these places. For example, ``return``s are not supported in
5470-
parsers, and `switch` statements are only supported in control
5471-
blocks. We present here the most general case, for control blocks.
5469+
each of these places. For example, neither ``return``s nor `switch`
5470+
statements are supported in parsers. We present here the most general
5471+
case, for control blocks.
54725472

54735473
[source,bison]
54745474
----
@@ -5621,7 +5621,8 @@ innermost `if` statement that does not have an `else` statement.
56215621
[#sec-switch-stmt]
56225622
=== Switch statement
56235623

5624-
The `switch` statement can only be used within `control` blocks.
5624+
The `switch` statement can only be used within `control` blocks, `action`
5625+
bodies, or function bodies.
56255626

56265627
[source,bison]
56275628
----
@@ -5646,9 +5647,10 @@ separately in the following two subsections.
56465647

56475648
==== Switch statement with `action_run` expression
56485649

5649-
For this variant of `switch` statement, the expression must be of the
5650-
form `t.apply().action_run`, where `t` is the name of a table (see
5651-
<<sec-invoke-mau>>). All switch labels must be names of
5650+
This type of `switch` statement can only be used within control `apply`
5651+
blocks. For this variant of `switch` statement, the expression must be
5652+
of the form `t.apply().action_run`, where `t` is the name of a table
5653+
(see <<sec-invoke-mau>>). All switch labels must be names of
56525654
actions of the table `t`, or `default`.
56535655

56545656
[source,p4]
@@ -9074,6 +9076,9 @@ The P4 compiler should provide:
90749076

90759077
=== Summary of changes made in unreleased version
90769078

9079+
* Clarified that numeric priorities cannot be assigned to entries of a table that has `const entries` (<<sec-entries>>).
9080+
* Clarified that `switch` statements are allowed in action and function bodies, and that `switch` statements with `action_run` expressions are only allowed in control `apply` blocks (<<sec-stmts>> and <<sec-switch-stmt>>).
9081+
90779082
=== Summary of changes made in version 1.2.5, released October 11, 2024
90789083

90799084
* Improved type nesting rules (<<#sec-type-nesting>>).

0 commit comments

Comments
 (0)