authorgravatar for mlugg@mlugg.co.ukMatthew Lugg <mlugg@mlugg.co.uk> 2026-03-05 22:13:22+00:00
committergravatar for mlugg@mlugg.co.ukMatthew Lugg <mlugg@mlugg.co.uk> 2026-03-10 10:38:50+00:00
log34d780f4bbefa8344cae5da49fe84bed83d8274f
tree9764659edc6d7e5d8bf9b12db679a6bb5cf3be4a
parentce1f28a7497903cf00431d6976c162c37683232a
signaturelock-open Commit is signed but in an unrecognized format.

langref: update for language changes


4 files changed, 16 insertions(+), 13 deletions(-)

doc/langref.html.in+3-2
......@@ -2103,8 +2103,9 @@ or
21032103 less than {#syntax#}1 << 29{#endsyntax#}.
21042104 </p>
21052105 <p>
2106 In Zig, a pointer type has an alignment value. If the value is equal to the
2107 alignment of the underlying type, it can be omitted from the type:
2106 Pointer types may explicitly specify an alignment in bytes. If it is not
2107 specified, the alignment is assumed to be equal to the alignment of the
2108 underlying type.
21082109 </p>
21092110 {#code|test_variable_alignment.zig#}
21102111
doc/langref/test_comptime_invalid_error_code.zig+2-5
......@@ -1,8 +1,5 @@
11comptime {
2 const err = error.AnError;
3 const number = @intFromError(err) + 10;
4 const invalid_err = @errorFromInt(number);
5 _ = invalid_err;
2 _ = @errorFromInt(12345);
63}
74
8// test_error=integer value '11' represents no error
5// test_error=integer value '12345' represents no error
doc/langref/test_missized_packed_struct.zig+1-1
......@@ -3,4 +3,4 @@ test "missized packed struct" {
33 _ = S{ .a = 4, .b = 2 };
44}
55
6// test_error=backing integer type 'u32' has bit size 32 but the struct fields have a total bit size of 24
6// test_error=backing integer bit width does not match total bit width of fields
doc/langref/test_variable_alignment.zig+10-5
......@@ -1,15 +1,20 @@
11const std = @import("std");
22const builtin = @import("builtin");
3const expect = std.testing.expect;
34const expectEqual = std.testing.expectEqual;
45
56test "variable alignment" {
67 var x: i32 = 1234;
7 const align_of_i32 = @alignOf(@TypeOf(x));
8
89 try expectEqual(*i32, @TypeOf(&x));
9 try expectEqual(*align(align_of_i32) i32, *i32);
10 if (builtin.target.cpu.arch == .x86_64) {
11 try expectEqual(4, @typeInfo(*i32).pointer.alignment);
12 }
10
11 try expect(@intFromPtr(&x) % @alignOf(i32) == 0);
12
13 // The implicitly-aligned pointer can be coerced to be explicitly-aligned to
14 // the alignment of the underlying type `i32`:
15 const ptr: *align(@alignOf(i32)) i32 = &x;
16
17 try expectEqual(1234, ptr.*);
1318}
1419
1520// test