authorgravatar for mlugg@mlugg.co.ukMatthew Lugg <mlugg@mlugg.co.uk> 2025-07-31 02:32:32+01:00
committergravatar for noreply@github.comGitHub <noreply@github.com> 2025-07-31 02:32:32+01:00
log032bbd68a7a17b4f8167f9644430c375f43da60c
treebb457848c0dfcad4dbc7f55d05172a9e31973007
parentde23ccfad1630e30d5b5ea1278ab2f375f987568
parent2dea904d5a1602674d9cd147f8a5f2797dd00c40
signaturebadge-check Signed by PGP key B5690EEEBB952194

Merge pull request #24537 from IOKG04/some-documentation-updates-0

some small langref changes

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

doc/langref.html.in+4-4
...@@ -3215,7 +3215,7 @@ fn createFoo(param: i32) !Foo {...@@ -3215,7 +3215,7 @@ fn createFoo(param: i32) !Foo {
3215 to increase their development pace.3215 to increase their development pace.
3216 </p>3216 </p>
3217 <p>3217 <p>
3218 Error Return Traces are enabled by default in {#link|Debug#} and {#link|ReleaseSafe#} builds and disabled by default in {#link|ReleaseFast#} and {#link|ReleaseSmall#} builds.3218 Error Return Traces are enabled by default in {#link|Debug#} builds and disabled by default in {#link|ReleaseFast#}, {#link|ReleaseSafe#} and {#link|ReleaseSmall#} builds.
3219 </p>3219 </p>
3220 <p>3220 <p>
3221 There are a few ways to activate this error return tracing feature:3221 There are a few ways to activate this error return tracing feature:
...@@ -4840,7 +4840,7 @@ fn cmpxchgWeakButNotAtomic(comptime T: type, ptr: *T, expected_value: T, new_val...@@ -4840,7 +4840,7 @@ fn cmpxchgWeakButNotAtomic(comptime T: type, ptr: *T, expected_value: T, new_val
4840 <p>4840 <p>
4841 This builtin can be called from a {#link|comptime#} block to conditionally export symbols.4841 This builtin can be called from a {#link|comptime#} block to conditionally export symbols.
4842 When <code>ptr</code> points to a function with the C calling convention and4842 When <code>ptr</code> points to a function with the C calling convention and
4843 {#syntax#}options.linkage{#endsyntax#} is {#syntax#}.Strong{#endsyntax#}, this is equivalent to4843 {#syntax#}options.linkage{#endsyntax#} is {#syntax#}.strong{#endsyntax#}, this is equivalent to
4844 the {#syntax#}export{#endsyntax#} keyword used on a function:4844 the {#syntax#}export{#endsyntax#} keyword used on a function:
4845 </p>4845 </p>
4846 {#code|export_builtin.zig#}4846 {#code|export_builtin.zig#}
...@@ -5179,7 +5179,7 @@ fn cmpxchgWeakButNotAtomic(comptime T: type, ptr: *T, expected_value: T, new_val...@@ -5179,7 +5179,7 @@ fn cmpxchgWeakButNotAtomic(comptime T: type, ptr: *T, expected_value: T, new_val
5179 <pre>{#syntax#}@mod(numerator: T, denominator: T) T{#endsyntax#}</pre>5179 <pre>{#syntax#}@mod(numerator: T, denominator: T) T{#endsyntax#}</pre>
5180 <p>5180 <p>
5181 Modulus division. For unsigned integers this is the same as5181 Modulus division. For unsigned integers this is the same as
5182 {#syntax#}numerator % denominator{#endsyntax#}. Caller guarantees {#syntax#}denominator > 0{#endsyntax#}, otherwise the5182 {#syntax#}numerator % denominator{#endsyntax#}. Caller guarantees {#syntax#}denominator != 0{#endsyntax#}, otherwise the
5183 operation will result in a {#link|Remainder Division by Zero#} when runtime safety checks are enabled.5183 operation will result in a {#link|Remainder Division by Zero#} when runtime safety checks are enabled.
5184 </p>5184 </p>
5185 <ul>5185 <ul>
...@@ -5284,7 +5284,7 @@ fn cmpxchgWeakButNotAtomic(comptime T: type, ptr: *T, expected_value: T, new_val...@@ -5284,7 +5284,7 @@ fn cmpxchgWeakButNotAtomic(comptime T: type, ptr: *T, expected_value: T, new_val
5284 <pre>{#syntax#}@rem(numerator: T, denominator: T) T{#endsyntax#}</pre>5284 <pre>{#syntax#}@rem(numerator: T, denominator: T) T{#endsyntax#}</pre>
5285 <p>5285 <p>
5286 Remainder division. For unsigned integers this is the same as5286 Remainder division. For unsigned integers this is the same as
5287 {#syntax#}numerator % denominator{#endsyntax#}. Caller guarantees {#syntax#}denominator > 0{#endsyntax#}, otherwise the5287 {#syntax#}numerator % denominator{#endsyntax#}. Caller guarantees {#syntax#}denominator != 0{#endsyntax#}, otherwise the
5288 operation will result in a {#link|Remainder Division by Zero#} when runtime safety checks are enabled.5288 operation will result in a {#link|Remainder Division by Zero#} when runtime safety checks are enabled.
5289 </p>5289 </p>
5290 <ul>5290 <ul>
doc/langref/test_coerce_slices_arrays_and_pointers.zig+7
...@@ -67,4 +67,11 @@ test "*T to *[1]T" {...@@ -67,4 +67,11 @@ test "*T to *[1]T" {
67 try expect(z[0] == 1234);67 try expect(z[0] == 1234);
68}68}
6969
70// Sentinel-terminated slices can be coerced into sentinel-terminated pointers
71test "[:x]T to [*:x]T" {
72 const buf: [:0]const u8 = "hello";
73 const buf2: [*:0]const u8 = buf;
74 try expect(buf2[4] == 'o');
75}
76
70// test77// test
test/behavior/math.zig+2
...@@ -525,6 +525,8 @@ fn testIntDivision() !void {...@@ -525,6 +525,8 @@ fn testIntDivision() !void {
525 try expect(rem(i32, 10, 12) == 10);525 try expect(rem(i32, 10, 12) == 10);
526 try expect(rem(i32, -14, 12) == -2);526 try expect(rem(i32, -14, 12) == -2);
527 try expect(rem(i32, -2, 12) == -2);527 try expect(rem(i32, -2, 12) == -2);
528 try expect(rem(i32, 118, -12) == 10);
529 try expect(rem(i32, -14, -12) == -2);
528 try expect(rem(i16, -118, 12) == -10);530 try expect(rem(i16, -118, 12) == -10);
529531
530 try expect(divTrunc(i20, 20, -5) == -4);532 try expect(divTrunc(i20, 20, -5) == -4);