From 29f793b3bf0316efba5085d9c3f4c9ca98e1b2cf Mon Sep 17 00:00:00 2001 From: Ryan Liptak Date: Fri, 16 Oct 2026 00:03:55 -0700 Subject: [PATCH] langref: another pass at the precedence tables section --- doc/langref.html.in | 51 +++++++++++++++++++++++++++++++-------------- 1 file changed, 35 insertions(+), 16 deletions(-) diff --git a/doc/langref.html.in b/doc/langref.html.in index df9af26b30173ad8dbf4aae164918fd14ee2781b..0a57deea52f9ea3917336304810decddae6516ee 100644 --- a/doc/langref.html.in +++ b/doc/langref.html.in @@ -1906,47 +1906,66 @@ const B = error{Two}; {#code|ambiguous_precedence_orelse.zig#}

- Simplified operator precedence tables are provided below, each tailored to a general group of - operators. For all of the groups shown below, the operators that have higher precedence are - the same, and themselves have the following precedence table: + There is a set of operators (prefix operators, suffix operators, etc) that have unambiguously + higher precedence than all other operators. That set of operators has the following precedence table:

{#syntax#}x() x[] x.y x.* x.?
 a!b
 x{}
-!x -x -%x ~x &x ?x try{#endsyntax#}
+!x -x -%x ~x &x ?x try +// lower precedence operators omitted{#endsyntax#}

- For the tables below, the operators that have ambiguous precedence or semantic errors with the - given operators have been omitted, as have operators with higher precedence. - The operators colored red and - blue have ambiguous precedence with the other operators - on the same line. Those colored red also have ambiguous + For the other operators, simplified operator precedence tables are provided below, each containing only + the information that you'll need to know when reading/writing code that uses that particular category of operators. + The operators that have ambiguous precedence or semantic errors with the relevant operators have been omitted, + as have the operators with higher precedence (those shown above). +

+ + + +

For arithmetic operators:

-
* / *% *| %
+      
* / *% *| %
 + - +% -% +| -|
-== != < > <= >=
-and or
+== != < > <= >= +and or

For bitwise operators:

-
<< <<| >> & ^ |
-== != < > <= >=
-and or
+
<< <<| >> & ^ |
+== != < > <= >=
+and or

For null and error recovery operators:

-
catch orelse
+
catch orelse

For error set operators: -- 2.54.0