You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[#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
Copy file name to clipboardExpand all lines: p4-16/spec/P4-16-spec.adoc
+13-8Lines changed: 13 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5463,12 +5463,12 @@ Statements can appear in several places:
5463
5463
5464
5464
* Within `parser` states
5465
5465
* Within a `control` block
5466
-
* Within an `action`
5466
+
* Within an `action` or function
5467
5467
5468
5468
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.
5472
5472
5473
5473
[source,bison]
5474
5474
----
@@ -5621,7 +5621,8 @@ innermost `if` statement that does not have an `else` statement.
5621
5621
[#sec-switch-stmt]
5622
5622
=== Switch statement
5623
5623
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.
5625
5626
5626
5627
[source,bison]
5627
5628
----
@@ -5646,9 +5647,10 @@ separately in the following two subsections.
5646
5647
5647
5648
==== Switch statement with `action_run` expression
5648
5649
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
5652
5654
actions of the table `t`, or `default`.
5653
5655
5654
5656
[source,p4]
@@ -9074,6 +9076,9 @@ The P4 compiler should provide:
9074
9076
9075
9077
=== Summary of changes made in unreleased version
9076
9078
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
+
9077
9082
=== Summary of changes made in version 1.2.5, released October 11, 2024
9078
9083
9079
9084
* Improved type nesting rules (<<#sec-type-nesting>>).
0 commit comments