authorgravatar for mlugg@mlugg.co.ukMatthew Lugg <mlugg@mlugg.co.uk> 2026-04-29 21:51:13+01:00
committergravatar for mlugg@mlugg.co.ukMatthew Lugg <mlugg@mlugg.co.uk> 2026-04-30 09:03:58+01:00
logbb83883acd9dee65423e836729eb0242c5e218ca
treec81bd55f63788495753a0086ec655e10427c8f1a
parentc144003fca989780bb4dccefc2a289bcbfb9969b
signaturelock-open Commit is signed but in an unrecognized format.

langref: update for language changes


6 files changed, 10 insertions(+), 68 deletions(-)

doc/langref.html.in+6-36
......@@ -624,11 +624,6 @@
624624 <td><code class="c">void</code></td>
625625 <td>Used for type-erased pointers.</td>
626626 </tr>
627 <tr>
628 <th scope="row">{#syntax#}void{#endsyntax#}</th>
629 <td>(none)</td>
630 <td>Always the value {#syntax#}void{}{#endsyntax#}</td>
631 </tr>
632627 <tr>
633628 <th scope="row">{#syntax#}noreturn{#endsyntax#}</th>
634629 <td>(none)</td>
......@@ -1806,25 +1801,6 @@ const together = array1 ++ array2;
18061801mem.eql(u32, &together, &[_]u32{1,2,3,4}){#endsyntax#}</pre>
18071802 </td>
18081803 </tr>
1809 <tr>
1810 <td>Array Multiplication</td>
1811 <td><pre>{#syntax#}a ** b{#endsyntax#}</pre></td>
1812 <td>
1813 <ul>
1814 <li>{#link|Arrays#}</li>
1815 </ul>
1816 </td>
1817 <td>
1818 <ul>
1819 <li>Only available when the length of {#syntax#}a{#endsyntax#} and {#syntax#}b{#endsyntax#} are {#link|compile-time known|comptime#}.</li>
1820 </ul>
1821 </td>
1822 <td>
1823 <pre>{#syntax#}const mem = @import("std").mem;
1824const pattern = "ab" ** 3;
1825mem.eql(u8, pattern, "ababab"){#endsyntax#}</pre>
1826 </td>
1827 </tr>
18281804 <tr>
18291805 <td>Pointer Dereference</td>
18301806 <td><pre>{#syntax#}a.*{#endsyntax#}</pre></td>
......@@ -1882,7 +1858,7 @@ const B = error{Two};
18821858a!b
18831859x{}
18841860!x -x -%x ~x &x ?x
1885* / % ** *% *| ||
1861* / % *% *| ||
18861862+ - ++ +% -% +| -|
18871863<< >> <<|
18881864& ^ | orelse catch
......@@ -2371,7 +2347,7 @@ or
23712347 </p>
23722348 <p>
23732349 Like arrays, tuples have a .len field, can be indexed (provided the index is comptime-known)
2374 and work with the ++ and ** operators. They can also be iterated over with {#link|inline for#}.
2350 and work with the ++ operator. They can also be iterated over with {#link|inline for#}.
23752351 </p>
23762352 {#code|test_tuples.zig#}
23772353
......@@ -2571,7 +2547,7 @@ or
25712547 {#header_close#}
25722548
25732549 {#header_open|Empty Blocks#}
2574 <p>An empty block is equivalent to {#syntax#}void{}{#endsyntax#}:</p>
2550 <p>An empty block returns the single value of type {#syntax#}void{#endsyntax#}:</p>
25752551 {#code|test_empty_block.zig#}
25762552
25772553 {#header_close#}
......@@ -3159,10 +3135,6 @@ fn createFoo(param: i32) !Foo {
31593135 the verbosity and cognitive overhead of trying to make sure every exit path
31603136 is covered. The deallocation code is always directly following the allocation code.
31613137 </p>
3162 <p>
3163 The {#syntax#}errdefer{#endsyntax#} statement can optionally capture the error:
3164 </p>
3165 {#code|test_errdefer_capture.zig#}
31663138 {#header_close#}
31673139 <p>
31683140 A couple of other tidbits about error handling:
......@@ -3627,7 +3599,7 @@ void do_a_thing(struct Foo *foo) {
36273599 <p>For some types, {#link|@sizeOf#} is 0:</p>
36283600 <ul>
36293601 <li>{#link|void#}</li>
3630 <li>The {#link|Integers#} {#syntax#}u0{#endsyntax#} and {#syntax#}i0{#endsyntax#}.</li>
3602 <li>The {#link|integer type|Integers#} {#syntax#}u0{#endsyntax#}.</li>
36313603 <li>{#link|Arrays#} and {#link|Vectors#} with len 0, or with an element type that is a zero bit type.</li>
36323604 <li>An {#link|enum#} with only 1 tag.</li>
36333605 <li>A {#link|struct#} with all fields being zero bit types.</li>
......@@ -8036,7 +8008,6 @@ MultiplyOp
80368008 / ASTERISK
80378009 / SLASH
80388010 / PERCENT
8039 / ASTERISK2
80408011 / ASTERISKPERCENT
80418012 / ASTERISKPIPE
80428013
......@@ -8083,11 +8054,11 @@ LabelableExpr
80838054# Ptr specific
80848055SliceTypeStart <- LBRACKET (COLON Expr)? RBRACKET
80858056
8086SinglePtrTypeStart <- ASTERISK / ASTERISK2
8057SinglePtrTypeStart <- ASTERISK
80878058
80888059ManyPtrTypeStart <- LBRACKET ASTERISK (LETTERC / COLON Expr)? RBRACKET
80898060
8090ArrayTypeStart <- LBRACKET Expr !(ASTERISK / ASTERISK2) (COLON Expr)? RBRACKET
8061ArrayTypeStart <- LBRACKET Expr !ASTERISK (COLON Expr)? RBRACKET
80918062
80928063# ContainerDecl specific
80938064ContainerDeclAuto <- ContainerDeclType LBRACE ContainerMembers RBRACE
......@@ -8215,7 +8186,6 @@ BUILTINIDENTIFIER <- '@'[A-Za-z_][A-Za-z0-9_]* skip
82158186AMPERSAND <- '&' ![=] skip
82168187AMPERSANDEQUAL <- '&=' skip
82178188ASTERISK <- '*' ![*%=|] skip
8218ASTERISK2 <- '**' skip
82198189ASTERISKEQUAL <- '*=' skip
82208190ASTERISKPERCENT <- '*%' ![=] skip
82218191ASTERISKPERCENTEQUAL <- '*%=' skip
doc/langref/test_arrays.zig+2-8
......@@ -60,14 +60,8 @@ comptime {
6060 assert(mem.eql(u8, hello_world, "hello world"));
6161}
6262
63// ** does repeating patterns
64const pattern = "ab" ** 3;
65comptime {
66 assert(mem.eql(u8, pattern, "ababab"));
67}
68
6963// initialize an array to zero
70const all_zero = [_]u16{0} ** 10;
64const all_zero: [10]u16 = @splat(0);
7165
7266comptime {
7367 assert(all_zero.len == 10);
......@@ -96,7 +90,7 @@ test "compile-time array initialization" {
9690}
9791
9892// call a function to initialize an array
99var more_points = [_]Point{makePoint(3)} ** 10;
93var more_points: [10]Point = @splat(makePoint(3));
10094fn makePoint(x: i32) Point {
10195 return Point{
10296 .x = x,
doc/langref/test_empty_block.zig-3
......@@ -3,10 +3,7 @@ const expectEqual = std.testing.expectEqual;
33
44test {
55 const a = {};
6 const b = void{};
76 try expectEqual(void, @TypeOf(a));
8 try expectEqual(void, @TypeOf(b));
9 try expectEqual(a, b);
107}
118
129// test
doc/langref/test_errdefer_capture.zig deleted-19
......@@ -1,19 +0,0 @@
1const std = @import("std");
2
3fn captureError(captured: *?anyerror) !void {
4 errdefer |err| {
5 captured.* = err;
6 }
7 return error.GeneralFailure;
8}
9
10test "errdefer capture" {
11 var captured: ?anyerror = null;
12
13 if (captureError(&captured)) unreachable else |err| {
14 try std.testing.expectEqual(error.GeneralFailure, captured.?);
15 try std.testing.expectEqual(error.GeneralFailure, err);
16 }
17}
18
19// test
doc/langref/test_multidimensional_arrays.zig+1-1
......@@ -24,7 +24,7 @@ test "multidimensional arrays" {
2424 }
2525
2626 // Initialize a multidimensional array to zeros.
27 const all_zero: [4][5]f32 = .{.{0} ** 5} ** 4;
27 const all_zero: [4][5]f32 = @splat(@splat(0));
2828 try expectEqual(0, all_zero[0][0]);
2929}
3030
doc/langref/test_tuples.zig+1-1
......@@ -8,7 +8,7 @@ test "tuple" {
88 @as(f64, 12.34),
99 true,
1010 "hi",
11 } ++ .{false} ** 2;
11 } ++ .{ false, false };
1212 try expectEqual(1234, values[0]);
1313 try expectEqual(false, values[4]);
1414 inline for (values, 0..) |v, i| {