@zigc/lib 0.17.0-dev.228 → 0.17.0-dev.242
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/compiler/build_runner.zig +1 -1
- package/compiler/reduce/Walk.zig +1 -6
- package/compiler/resinator/cvtres.zig +4 -4
- package/compiler/resinator/ico.zig +4 -4
- package/compiler/resinator/parse.zig +2 -2
- package/compiler/resinator/res.zig +1 -1
- package/compiler/translate-c/ast.zig +11 -21
- package/compiler_rt/atomics.zig +1 -1
- package/compiler_rt/ssp.zig +2 -2
- package/docs/wasm/Walk.zig +1 -3
- package/docs/wasm/html_render.zig +1 -2
- package/package.json +1 -1
- package/std/Io/Reader.zig +0 -5
- package/std/Io/Threaded.zig +4 -4
- package/std/Io/Writer.zig +1 -2
- package/std/Io/net/HostName.zig +11 -6
- package/std/Random/ChaCha.zig +2 -2
- package/std/Random/benchmark.zig +2 -2
- package/std/Thread.zig +2 -2
- package/std/base64.zig +5 -5
- package/std/bit_set.zig +7 -7
- package/std/c.zig +17 -17
- package/std/compress/flate/Decompress.zig +1 -1
- package/std/crypto/25519/curve25519.zig +2 -2
- package/std/crypto/25519/edwards25519.zig +3 -3
- package/std/crypto/25519/ristretto255.zig +2 -2
- package/std/crypto/25519/scalar.zig +6 -6
- package/std/crypto/25519/x25519.zig +1 -1
- package/std/crypto/Certificate.zig +1 -1
- package/std/crypto/Sha1.zig +1 -1
- package/std/crypto/aegis.zig +45 -39
- package/std/crypto/aes_ccm.zig +20 -20
- package/std/crypto/aes_gcm.zig +10 -12
- package/std/crypto/aes_ocb.zig +9 -9
- package/std/crypto/argon2.zig +15 -15
- package/std/crypto/bcrypt.zig +20 -10
- package/std/crypto/benchmark.zig +7 -7
- package/std/crypto/blake2.zig +100 -64
- package/std/crypto/cbc_mac.zig +1 -1
- package/std/crypto/chacha20.zig +10 -10
- package/std/crypto/cmac.zig +2 -2
- package/std/crypto/codecs/asn1.zig +1 -1
- package/std/crypto/ecdsa.zig +9 -9
- package/std/crypto/ff.zig +2 -2
- package/std/crypto/ghash_polyval.zig +4 -4
- package/std/crypto/hkdf.zig +1 -1
- package/std/crypto/isap.zig +3 -3
- package/std/crypto/kangarootwelve.zig +1 -1
- package/std/crypto/keccak_p.zig +7 -7
- package/std/crypto/md5.zig +1 -1
- package/std/crypto/ml_dsa.zig +33 -33
- package/std/crypto/ml_kem.zig +4 -4
- package/std/crypto/modes.zig +1 -1
- package/std/crypto/pbkdf2.zig +1 -1
- package/std/crypto/pcurves/p256/scalar.zig +3 -3
- package/std/crypto/pcurves/p384/scalar.zig +2 -2
- package/std/crypto/pcurves/secp256k1/scalar.zig +3 -3
- package/std/crypto/pcurves/tests/p256.zig +5 -5
- package/std/crypto/pcurves/tests/p384.zig +5 -5
- package/std/crypto/pcurves/tests/secp256k1.zig +3 -3
- package/std/crypto/salsa20.zig +8 -8
- package/std/crypto/sha2.zig +2 -2
- package/std/crypto/sha3.zig +2 -2
- package/std/crypto/siphash.zig +1 -1
- package/std/crypto/timing_safe.zig +5 -4
- package/std/crypto/tls/Client.zig +10 -9
- package/std/crypto.zig +3 -3
- package/std/debug/Dwarf.zig +1 -1
- package/std/debug.zig +6 -4
- package/std/elf.zig +1 -1
- package/std/enums.zig +1 -1
- package/std/fmt/parse_float/decimal.zig +1 -1
- package/std/fmt.zig +5 -1
- package/std/hash/Adler32.zig +3 -3
- package/std/hash/benchmark.zig +2 -2
- package/std/hash/wyhash.zig +1 -1
- package/std/heap/debug_allocator.zig +1 -1
- package/std/http.zig +1 -1
- package/std/json/static.zig +2 -2
- package/std/math/big/int.zig +3 -3
- package/std/math/nextafter.zig +1 -2
- package/std/math/powi.zig +2 -3
- package/std/math/signbit.zig +0 -1
- package/std/math.zig +12 -18
- package/std/mem.zig +9 -8
- package/std/meta.zig +1 -1
- package/std/os/emscripten.zig +2 -2
- package/std/os/linux.zig +4 -4
- package/std/os/uefi/hii.zig +1 -1
- package/std/tar/Writer.zig +39 -33
- package/std/tar.zig +8 -4
- package/std/unicode.zig +13 -8
- package/std/zig/Ast/Render.zig +1 -25
- package/std/zig/Ast.zig +5 -28
- package/std/zig/AstGen.zig +75 -184
- package/std/zig/AstRlAnnotate.zig +1 -11
- package/std/zig/AstSmith.zig +5 -11
- package/std/zig/LibCInstallation.zig +1 -1
- package/std/zig/Parse.zig +4 -69
- package/std/zig/TokenSmith.zig +0 -6
- package/std/zig/WindowsSdk.zig +1 -1
- package/std/zig/Zir.zig +0 -54
- package/std/zig/ZonGen.zig +0 -1
- package/std/zig/llvm/Builder.zig +3 -7
- package/std/zig/tokenizer.zig +4 -43
- package/std/zig.zig +0 -2
package/std/mem.zig
CHANGED
|
@@ -359,7 +359,10 @@ test zeroes {
|
|
|
359
359
|
var a = zeroes(C_struct);
|
|
360
360
|
|
|
361
361
|
// Extern structs should have padding zeroed out.
|
|
362
|
-
|
|
362
|
+
{
|
|
363
|
+
const num_bytes = @sizeOf(@TypeOf(a));
|
|
364
|
+
try testing.expectEqualSlices(u8, &@as([num_bytes]u8, @splat(0)), @ptrCast(&a));
|
|
365
|
+
}
|
|
363
366
|
|
|
364
367
|
a.y += 10;
|
|
365
368
|
|
|
@@ -370,7 +373,6 @@ test zeroes {
|
|
|
370
373
|
comptime comptime_field: u8 = 5,
|
|
371
374
|
|
|
372
375
|
integral_types: struct {
|
|
373
|
-
integer_0: i0,
|
|
374
376
|
integer_8: i8,
|
|
375
377
|
integer_16: i16,
|
|
376
378
|
integer_32: i32,
|
|
@@ -405,7 +407,6 @@ test zeroes {
|
|
|
405
407
|
|
|
406
408
|
const b = zeroes(ZigStruct);
|
|
407
409
|
try testing.expectEqual(@as(u8, 5), b.comptime_field);
|
|
408
|
-
try testing.expectEqual(@as(i8, 0), b.integral_types.integer_0);
|
|
409
410
|
try testing.expectEqual(@as(i8, 0), b.integral_types.integer_8);
|
|
410
411
|
try testing.expectEqual(@as(i16, 0), b.integral_types.integer_16);
|
|
411
412
|
try testing.expectEqual(@as(i32, 0), b.integral_types.integer_32);
|
|
@@ -1589,7 +1590,7 @@ test find {
|
|
|
1589
1590
|
test "find multibyte" {
|
|
1590
1591
|
{
|
|
1591
1592
|
// make haystack and needle long enough to trigger Boyer-Moore-Horspool algorithm
|
|
1592
|
-
const haystack = [
|
|
1593
|
+
const haystack = @as([100]u16, @splat(0)) ++ [_]u16{ 0xbbaa, 0xccbb, 0xddcc, 0xeedd, 0xffee, 0x00ff };
|
|
1593
1594
|
const needle = [_]u16{ 0xbbaa, 0xccbb, 0xddcc, 0xeedd, 0xffee };
|
|
1594
1595
|
try testing.expectEqual(findPos(u16, &haystack, 0, &needle), 100);
|
|
1595
1596
|
|
|
@@ -1602,7 +1603,7 @@ test "find multibyte" {
|
|
|
1602
1603
|
|
|
1603
1604
|
{
|
|
1604
1605
|
// make haystack and needle long enough to trigger Boyer-Moore-Horspool algorithm
|
|
1605
|
-
const haystack = [_]u16{ 0xbbaa, 0xccbb, 0xddcc, 0xeedd, 0xffee, 0x00ff } ++ [
|
|
1606
|
+
const haystack = [_]u16{ 0xbbaa, 0xccbb, 0xddcc, 0xeedd, 0xffee, 0x00ff } ++ @as([100]u16, @splat(0));
|
|
1606
1607
|
const needle = [_]u16{ 0xbbaa, 0xccbb, 0xddcc, 0xeedd, 0xffee };
|
|
1607
1608
|
try testing.expectEqual(lastIndexOf(u16, &haystack, &needle), 0);
|
|
1608
1609
|
|
|
@@ -4647,7 +4648,7 @@ test "sliceAsBytes with sentinel slice" {
|
|
|
4647
4648
|
}
|
|
4648
4649
|
|
|
4649
4650
|
test "sliceAsBytes with zero-bit element type" {
|
|
4650
|
-
const lots_of_nothing
|
|
4651
|
+
const lots_of_nothing: [10_000]void = @splat({});
|
|
4651
4652
|
const bytes = sliceAsBytes(&lots_of_nothing);
|
|
4652
4653
|
try testing.expect(bytes.len == 0);
|
|
4653
4654
|
}
|
|
@@ -4865,8 +4866,8 @@ test doNotOptimizeAway {
|
|
|
4865
4866
|
doNotOptimizeAway(@as(u200, 0));
|
|
4866
4867
|
doNotOptimizeAway(@as(f32, 0.0));
|
|
4867
4868
|
doNotOptimizeAway(@as(f64, 0.0));
|
|
4868
|
-
doNotOptimizeAway([
|
|
4869
|
-
doNotOptimizeAway([
|
|
4869
|
+
doNotOptimizeAway(@as([4]u8, @splat(0)));
|
|
4870
|
+
doNotOptimizeAway(@as([100]u8, @splat(0)));
|
|
4870
4871
|
doNotOptimizeAway(@as(std.builtin.Endian, .little));
|
|
4871
4872
|
}
|
|
4872
4873
|
|
package/std/meta.zig
CHANGED
|
@@ -1067,7 +1067,7 @@ test hasUniqueRepresentation {
|
|
|
1067
1067
|
|
|
1068
1068
|
try testing.expect(!hasUniqueRepresentation(TestUnion4));
|
|
1069
1069
|
|
|
1070
|
-
inline for ([_]type{
|
|
1070
|
+
inline for ([_]type{ u8, i16, u32, i64 }) |T| {
|
|
1071
1071
|
try testing.expect(hasUniqueRepresentation(T));
|
|
1072
1072
|
try testing.expect(hasUniqueRepresentation(enum(T) { _ }));
|
|
1073
1073
|
}
|
package/std/os/emscripten.zig
CHANGED
|
@@ -373,7 +373,7 @@ pub const rusage = extern struct {
|
|
|
373
373
|
nsignals: isize,
|
|
374
374
|
nvcsw: isize,
|
|
375
375
|
nivcsw: isize,
|
|
376
|
-
__reserved: [16]isize =
|
|
376
|
+
__reserved: [16]isize = @splat(0),
|
|
377
377
|
|
|
378
378
|
pub const SELF = 0;
|
|
379
379
|
pub const CHILDREN = -1;
|
|
@@ -481,7 +481,7 @@ pub const Sigaction = extern struct {
|
|
|
481
481
|
|
|
482
482
|
pub const sigset_t = [1024 / 32]u32;
|
|
483
483
|
pub fn sigemptyset() sigset_t {
|
|
484
|
-
return
|
|
484
|
+
return @splat(0);
|
|
485
485
|
}
|
|
486
486
|
pub const siginfo_t = extern struct {
|
|
487
487
|
signo: i32,
|
package/std/os/linux.zig
CHANGED
|
@@ -2262,12 +2262,12 @@ pub fn sigrtmax() u8 {
|
|
|
2262
2262
|
|
|
2263
2263
|
/// Zig's version of sigemptyset. Returns initialized sigset_t.
|
|
2264
2264
|
pub fn sigemptyset() sigset_t {
|
|
2265
|
-
return
|
|
2265
|
+
return @splat(0);
|
|
2266
2266
|
}
|
|
2267
2267
|
|
|
2268
2268
|
/// Zig's version of sigfillset. Returns initalized sigset_t.
|
|
2269
2269
|
pub fn sigfillset() sigset_t {
|
|
2270
|
-
return
|
|
2270
|
+
return @splat(~@as(SigsetElement, 0));
|
|
2271
2271
|
}
|
|
2272
2272
|
|
|
2273
2273
|
fn sigset_bit_index(sig: SIG) struct { word: usize, mask: SigsetElement } {
|
|
@@ -6129,7 +6129,7 @@ pub const sockaddr = extern struct {
|
|
|
6129
6129
|
flags: u8,
|
|
6130
6130
|
|
|
6131
6131
|
/// The total size of this structure should be exactly the same as that of struct sockaddr.
|
|
6132
|
-
zero: [3]u8 =
|
|
6132
|
+
zero: [3]u8 = @splat(0),
|
|
6133
6133
|
comptime {
|
|
6134
6134
|
std.debug.assert(@sizeOf(vm) == @sizeOf(sockaddr));
|
|
6135
6135
|
}
|
|
@@ -7475,7 +7475,7 @@ pub const rusage = extern struct {
|
|
|
7475
7475
|
nsignals: isize,
|
|
7476
7476
|
nvcsw: isize,
|
|
7477
7477
|
nivcsw: isize,
|
|
7478
|
-
__reserved: [16]isize =
|
|
7478
|
+
__reserved: [16]isize = @splat(0),
|
|
7479
7479
|
|
|
7480
7480
|
pub const SELF = 0;
|
|
7481
7481
|
pub const CHILDREN = -1;
|
package/std/os/uefi/hii.zig
CHANGED
package/std/tar/Writer.zig
CHANGED
|
@@ -193,23 +193,23 @@ pub const Header = extern struct {
|
|
|
193
193
|
// numeric field of width w contains w minus 1 digits, and a null.
|
|
194
194
|
// Reference: https://www.gnu.org/software/tar/manual/html_node/Standard.html
|
|
195
195
|
// POSIX header: byte offset
|
|
196
|
-
name: [100]u8 =
|
|
196
|
+
name: [100]u8 = @splat(0), // 0
|
|
197
197
|
mode: [7:0]u8 = default_mode.file, // 100
|
|
198
|
-
uid: [7:0]u8 =
|
|
199
|
-
gid: [7:0]u8 =
|
|
200
|
-
size: [11:0]u8 =
|
|
201
|
-
mtime: [11:0]u8 =
|
|
202
|
-
checksum: [7:0]u8 =
|
|
198
|
+
uid: [7:0]u8 = @splat(0), // unused 108
|
|
199
|
+
gid: [7:0]u8 = @splat(0), // unused 116
|
|
200
|
+
size: [11:0]u8 = @splat('0'), // 124
|
|
201
|
+
mtime: [11:0]u8 = @splat('0'), // 136
|
|
202
|
+
checksum: [7:0]u8 = @splat(' '), // 148
|
|
203
203
|
typeflag: FileType = .regular, // 156
|
|
204
|
-
linkname: [100]u8 =
|
|
205
|
-
magic: [6]u8 =
|
|
206
|
-
version: [2]u8 =
|
|
207
|
-
uname: [32]u8 =
|
|
208
|
-
gname: [32]u8 =
|
|
209
|
-
devmajor: [7:0]u8 =
|
|
210
|
-
devminor: [7:0]u8 =
|
|
211
|
-
prefix: [155]u8 =
|
|
212
|
-
pad: [12]u8 =
|
|
204
|
+
linkname: [100]u8 = @splat(0), // 157
|
|
205
|
+
magic: [6]u8 = .{ 'u', 's', 't', 'a', 'r', 0 }, // 257
|
|
206
|
+
version: [2]u8 = .{ '0', '0' }, // 263
|
|
207
|
+
uname: [32]u8 = @splat(0), // unused 265
|
|
208
|
+
gname: [32]u8 = @splat(0), // unused 297
|
|
209
|
+
devmajor: [7:0]u8 = @splat(0), // unused 329
|
|
210
|
+
devminor: [7:0]u8 = @splat(0), // unused 337
|
|
211
|
+
prefix: [155]u8 = @splat(0), // 345
|
|
212
|
+
pad: [12]u8 = @splat(0), // unused 500
|
|
213
213
|
|
|
214
214
|
pub const FileType = enum(u8) {
|
|
215
215
|
regular = '0',
|
|
@@ -342,26 +342,26 @@ pub const Header = extern struct {
|
|
|
342
342
|
},
|
|
343
343
|
// no more both fits into name
|
|
344
344
|
.{
|
|
345
|
-
.in = &.{ "prefix", "0123456789/"
|
|
346
|
-
.out = &.{ "prefix", "0123456789/"
|
|
345
|
+
.in = &.{ "prefix", repeatString(8, "0123456789/") ++ "basename" },
|
|
346
|
+
.out = &.{ "prefix", repeatString(8, "0123456789/") ++ "basename" },
|
|
347
347
|
},
|
|
348
348
|
// put as much as you can into prefix the rest goes into name
|
|
349
349
|
.{
|
|
350
|
-
.in = &.{ "prefix", "0123456789/"
|
|
351
|
-
.out = &.{ "prefix/" ++ "0123456789/"
|
|
350
|
+
.in = &.{ "prefix", repeatString(10, "0123456789/") ++ "basename" },
|
|
351
|
+
.out = &.{ "prefix/" ++ repeatString(9, "0123456789/") ++ "0123456789", "basename" },
|
|
352
352
|
},
|
|
353
353
|
|
|
354
354
|
.{
|
|
355
|
-
.in = &.{ "prefix", "0123456789/"
|
|
356
|
-
.out = &.{ "prefix/" ++ "0123456789/"
|
|
355
|
+
.in = &.{ "prefix", repeatString(15, "0123456789/") ++ "basename" },
|
|
356
|
+
.out = &.{ "prefix/" ++ repeatString(12, "0123456789/") ++ "0123456789", "0123456789/0123456789/basename" },
|
|
357
357
|
},
|
|
358
358
|
.{
|
|
359
|
-
.in = &.{ "prefix", "0123456789/"
|
|
360
|
-
.out = &.{ "prefix/" ++ "0123456789/"
|
|
359
|
+
.in = &.{ "prefix", repeatString(21, "0123456789/") ++ "basename" },
|
|
360
|
+
.out = &.{ "prefix/" ++ repeatString(12, "0123456789/") ++ "0123456789", repeatString(8, "0123456789/") ++ "basename" },
|
|
361
361
|
},
|
|
362
362
|
.{
|
|
363
|
-
.in = &.{ "", "012345678/"
|
|
364
|
-
.out = &.{ "012345678/"
|
|
363
|
+
.in = &.{ "", repeatString(10, "012345678/") ++ "foo" },
|
|
364
|
+
.out = &.{ repeatString(9, "012345678/") ++ "012345678", "foo" },
|
|
365
365
|
},
|
|
366
366
|
};
|
|
367
367
|
|
|
@@ -378,10 +378,10 @@ pub const Header = extern struct {
|
|
|
378
378
|
// basename can't fit into name (106 characters)
|
|
379
379
|
.{ .in = &.{ "zig", "test/cases/compile_errors/regression_test_2980_base_type_u32_is_not_type_checked_properly_when_assigning_a_value_within_a_struct.zig" } },
|
|
380
380
|
// cant fit into 255 + sep
|
|
381
|
-
.{ .in = &.{ "prefix", "0123456789/"
|
|
381
|
+
.{ .in = &.{ "prefix", repeatString(22, "0123456789/") ++ "basename" } },
|
|
382
382
|
// can fit but sub_path can't be split (there is no separator)
|
|
383
|
-
.{ .in = &.{ "prefix", "0123456789"
|
|
384
|
-
.{ .in = &.{ "prefix", "0123456789"
|
|
383
|
+
.{ .in = &.{ "prefix", repeatString(10, "0123456789") ++ "a" } },
|
|
384
|
+
.{ .in = &.{ "prefix", repeatString(14, "0123456789") ++ "basename" } },
|
|
385
385
|
};
|
|
386
386
|
|
|
387
387
|
for (error_cases) |case| {
|
|
@@ -404,11 +404,11 @@ test "write files" {
|
|
|
404
404
|
content: []const u8,
|
|
405
405
|
}{
|
|
406
406
|
.{ .path = "foo", .content = "bar" },
|
|
407
|
-
.{ .path = "a12345678/"
|
|
408
|
-
.{ .path = "b12345678/"
|
|
409
|
-
.{ .path = "c12345678/"
|
|
410
|
-
.{ .path = "d12345678/"
|
|
411
|
-
.{ .path = "e123456789"
|
|
407
|
+
.{ .path = repeatString(10, "a12345678/") ++ "foo", .content = repeatString(511, "a") },
|
|
408
|
+
.{ .path = repeatString(24, "b12345678/") ++ "foo", .content = repeatString(512, "b") },
|
|
409
|
+
.{ .path = repeatString(25, "c12345678/") ++ "foo", .content = repeatString(513, "c") },
|
|
410
|
+
.{ .path = repeatString(51, "d12345678/") ++ "foo", .content = repeatString(1025, "d") },
|
|
411
|
+
.{ .path = repeatString(11, "e123456789"), .content = "e" },
|
|
412
412
|
};
|
|
413
413
|
|
|
414
414
|
var file_name_buffer: [std.fs.max_path_bytes]u8 = undefined;
|
|
@@ -482,3 +482,9 @@ test "write files" {
|
|
|
482
482
|
try w.finishPedantically();
|
|
483
483
|
}
|
|
484
484
|
}
|
|
485
|
+
|
|
486
|
+
/// Marked `inline` to avoid unnecessary binary float, since arguments are always comptime-known.
|
|
487
|
+
inline fn repeatString(comptime n: usize, comptime str: []const u8) []const u8 {
|
|
488
|
+
const buf: [n][str.len]u8 = @splat(str[0..str.len].*);
|
|
489
|
+
return @ptrCast(&buf);
|
|
490
|
+
}
|
package/std/tar.zig
CHANGED
|
@@ -734,6 +734,10 @@ test PaxIterator {
|
|
|
734
734
|
value: []const u8 = undefined,
|
|
735
735
|
err: ?anyerror = null,
|
|
736
736
|
};
|
|
737
|
+
const long_path: *const [1000]u8 = comptime path: {
|
|
738
|
+
const buf: [100][10]u8 = @splat("0123456789".*);
|
|
739
|
+
break :path @ptrCast(&buf);
|
|
740
|
+
};
|
|
737
741
|
const cases = [_]struct {
|
|
738
742
|
data: []const u8,
|
|
739
743
|
attrs: []const Attr,
|
|
@@ -816,9 +820,9 @@ test PaxIterator {
|
|
|
816
820
|
},
|
|
817
821
|
},
|
|
818
822
|
.{ // 1000 characters path
|
|
819
|
-
.data = "1011 path=" ++
|
|
823
|
+
.data = "1011 path=" ++ long_path ++ "\n",
|
|
820
824
|
.attrs = &[_]Attr{
|
|
821
|
-
.{ .kind = .path, .value =
|
|
825
|
+
.{ .kind = .path, .value = long_path },
|
|
822
826
|
},
|
|
823
827
|
},
|
|
824
828
|
};
|
|
@@ -879,7 +883,7 @@ test "header parse size" {
|
|
|
879
883
|
};
|
|
880
884
|
|
|
881
885
|
for (cases) |case| {
|
|
882
|
-
var bytes
|
|
886
|
+
var bytes: [Header.SIZE]u8 = @splat(0);
|
|
883
887
|
@memcpy(bytes[124 .. 124 + case.in.len], case.in);
|
|
884
888
|
var header = Header{ .bytes = &bytes };
|
|
885
889
|
if (case.err) |err| {
|
|
@@ -904,7 +908,7 @@ test "header parse mode" {
|
|
|
904
908
|
.{ .in = "777777777777", .want = 0o77777777 },
|
|
905
909
|
};
|
|
906
910
|
for (cases) |case| {
|
|
907
|
-
var bytes
|
|
911
|
+
var bytes: [Header.SIZE]u8 = @splat(0);
|
|
908
912
|
@memcpy(bytes[100 .. 100 + case.in.len], case.in);
|
|
909
913
|
var header = Header{ .bytes = &bytes };
|
|
910
914
|
if (case.err) |err| {
|
package/std/unicode.zig
CHANGED
|
@@ -275,11 +275,16 @@ fn utf8ValidateSliceImpl(input: []const u8, comptime surrogates: Surrogates) boo
|
|
|
275
275
|
const s7 = 0x44; // accept 4, size 4
|
|
276
276
|
|
|
277
277
|
// Information about the first byte in a UTF-8 sequence.
|
|
278
|
-
const first = comptime
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
278
|
+
const first = comptime first: {
|
|
279
|
+
const a: [128]u8 = @splat(as);
|
|
280
|
+
const b: [64]u8 = @splat(xx);
|
|
281
|
+
const c: [64]u8 = .{
|
|
282
|
+
xx, xx, s1, s1, s1, s1, s1, s1, s1, s1, s1, s1, s1, s1, s1, s1,
|
|
283
|
+
s1, s1, s1, s1, s1, s1, s1, s1, s1, s1, s1, s1, s1, s1, s1, s1,
|
|
284
|
+
s2, s3, s3, s3, s3, s3, s3, s3, s3, s3, s3, s3, s3, s4, s3, s3,
|
|
285
|
+
s5, s6, s6, s6, s7, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx,
|
|
286
|
+
};
|
|
287
|
+
break :first a ++ b ++ c;
|
|
283
288
|
};
|
|
284
289
|
|
|
285
290
|
const n = remaining.len;
|
|
@@ -647,7 +652,7 @@ test "validate slice" {
|
|
|
647
652
|
|
|
648
653
|
// We skip a variable (based on recommended vector size) chunks of
|
|
649
654
|
// ASCII characters. Let's make sure we're chunking correctly.
|
|
650
|
-
const str = [
|
|
655
|
+
const str = @as([550]u8, @splat('a')) ++ "\xc0";
|
|
651
656
|
for (0..str.len - 3) |i| {
|
|
652
657
|
try testing.expect(!utf8ValidateSlice(str[i..]));
|
|
653
658
|
}
|
|
@@ -1394,7 +1399,7 @@ test "ArrayList functions on a re-used list" {
|
|
|
1394
1399
|
fn utf8ToUtf16LeStringLiteralImpl(comptime utf8: []const u8, comptime surrogates: Surrogates) *const [calcUtf16LeLenImpl(utf8, surrogates) catch |err| @compileError(err):0]u16 {
|
|
1395
1400
|
return comptime blk: {
|
|
1396
1401
|
const len: usize = calcUtf16LeLenImpl(utf8, surrogates) catch unreachable;
|
|
1397
|
-
var utf16le: [len:0]u16 =
|
|
1402
|
+
var utf16le: [len:0]u16 = @splat(0);
|
|
1398
1403
|
const utf16le_len = utf8ToUtf16LeImpl(&utf16le, utf8[0..], surrogates) catch |err| @compileError(err);
|
|
1399
1404
|
assert(len == utf16le_len);
|
|
1400
1405
|
const final = utf16le;
|
|
@@ -1640,7 +1645,7 @@ test "validate WTF-8 slice" {
|
|
|
1640
1645
|
|
|
1641
1646
|
// We skip a variable (based on recommended vector size) chunks of
|
|
1642
1647
|
// ASCII characters. Let's make sure we're chunking correctly.
|
|
1643
|
-
const str = [
|
|
1648
|
+
const str = @as([550]u8, @splat('a')) ++ "\xc0";
|
|
1644
1649
|
for (0..str.len - 3) |i| {
|
|
1645
1650
|
try testing.expect(!wtf8ValidateSlice(str[i..]));
|
|
1646
1651
|
}
|
package/std/zig/Ast/Render.zig
CHANGED
|
@@ -394,20 +394,8 @@ fn renderExpression(r: *Render, node: Ast.Node.Index, space: Space) Error!void {
|
|
|
394
394
|
return renderBlock(r, node, statements, space);
|
|
395
395
|
},
|
|
396
396
|
|
|
397
|
-
.@"errdefer" => {
|
|
398
|
-
const defer_token = tree.nodeMainToken(node);
|
|
399
|
-
const maybe_payload_token, const expr = tree.nodeData(node).opt_token_and_node;
|
|
400
|
-
|
|
401
|
-
try renderToken(r, defer_token, .maybe_space);
|
|
402
|
-
if (maybe_payload_token.unwrap()) |payload_token| {
|
|
403
|
-
try renderToken(r, payload_token - 1, .none); // |
|
|
404
|
-
try renderIdentifier(r, payload_token, .none, .preserve_when_shadowing); // identifier
|
|
405
|
-
try renderToken(r, payload_token + 1, .maybe_space); // |
|
|
406
|
-
}
|
|
407
|
-
return renderExpression(r, expr, space);
|
|
408
|
-
},
|
|
409
|
-
|
|
410
397
|
.@"defer",
|
|
398
|
+
.@"errdefer",
|
|
411
399
|
.@"comptime",
|
|
412
400
|
.@"nosuspend",
|
|
413
401
|
.@"suspend",
|
|
@@ -520,7 +508,6 @@ fn renderExpression(r: *Render, node: Ast.Node.Index, space: Space) Error!void {
|
|
|
520
508
|
.add_wrap,
|
|
521
509
|
.add_sat,
|
|
522
510
|
.array_cat,
|
|
523
|
-
.array_mult,
|
|
524
511
|
.bang_equal,
|
|
525
512
|
.bit_and,
|
|
526
513
|
.bit_or,
|
|
@@ -1040,16 +1027,6 @@ fn renderPtrType(r: *Render, ptr_type: Ast.full.PtrType, space: Space) Error!voi
|
|
|
1040
1027
|
|
|
1041
1028
|
switch (ptr_type.size) {
|
|
1042
1029
|
.one => {
|
|
1043
|
-
// Since ** tokens exist and the same token is shared by two
|
|
1044
|
-
// nested pointer types, we check to see if we are the parent
|
|
1045
|
-
// in such a relationship. If so, skip rendering anything for
|
|
1046
|
-
// this pointer type and rely on the child to render our asterisk
|
|
1047
|
-
// as well when it renders the ** token.
|
|
1048
|
-
if (tree.tokenTag(main_token) == .asterisk_asterisk and
|
|
1049
|
-
main_token == tree.nodeMainToken(ptr_type.ast.child_type))
|
|
1050
|
-
{
|
|
1051
|
-
return renderExpression(r, ptr_type.ast.child_type, space);
|
|
1052
|
-
}
|
|
1053
1030
|
try renderToken(r, main_token, .none); // asterisk
|
|
1054
1031
|
},
|
|
1055
1032
|
.many => {
|
|
@@ -3235,7 +3212,6 @@ fn nodeCausesSliceOpSpace(tag: Ast.Node.Tag) bool {
|
|
|
3235
3212
|
.add,
|
|
3236
3213
|
.add_wrap,
|
|
3237
3214
|
.array_cat,
|
|
3238
|
-
.array_mult,
|
|
3239
3215
|
.assign,
|
|
3240
3216
|
.assign_bit_and,
|
|
3241
3217
|
.assign_bit_or,
|
package/std/zig/Ast.zig
CHANGED
|
@@ -331,11 +331,6 @@ pub fn rootDecls(tree: Ast) []const Node.Index {
|
|
|
331
331
|
|
|
332
332
|
pub fn renderError(tree: Ast, parse_error: Error, w: *Writer) Writer.Error!void {
|
|
333
333
|
switch (parse_error.tag) {
|
|
334
|
-
.asterisk_after_ptr_deref => {
|
|
335
|
-
// Note that the token will point at the `.*` but ideally the source
|
|
336
|
-
// location would point to the `*` after the `.*`.
|
|
337
|
-
return w.writeAll("'.*' cannot be followed by '*'; are you missing a space?");
|
|
338
|
-
},
|
|
339
334
|
.chained_comparison_operators => {
|
|
340
335
|
return w.writeAll("comparison operators cannot be chained");
|
|
341
336
|
},
|
|
@@ -687,7 +682,6 @@ pub fn firstToken(tree: Ast, node: Node.Index) TokenIndex {
|
|
|
687
682
|
.mul,
|
|
688
683
|
.div,
|
|
689
684
|
.mod,
|
|
690
|
-
.array_mult,
|
|
691
685
|
.mul_wrap,
|
|
692
686
|
.mul_sat,
|
|
693
687
|
.add,
|
|
@@ -924,7 +918,6 @@ pub fn lastToken(tree: Ast, node: Node.Index) TokenIndex {
|
|
|
924
918
|
.mul,
|
|
925
919
|
.div,
|
|
926
920
|
.mod,
|
|
927
|
-
.array_mult,
|
|
928
921
|
.mul_wrap,
|
|
929
922
|
.mul_sat,
|
|
930
923
|
.add,
|
|
@@ -952,8 +945,8 @@ pub fn lastToken(tree: Ast, node: Node.Index) TokenIndex {
|
|
|
952
945
|
.switch_range,
|
|
953
946
|
=> n = tree.nodeData(n).node_and_node[1],
|
|
954
947
|
|
|
955
|
-
.test_decl
|
|
956
|
-
.@"defer" => n = tree.nodeData(n).node,
|
|
948
|
+
.test_decl => n = tree.nodeData(n).opt_token_and_node[1],
|
|
949
|
+
.@"defer", .@"errdefer" => n = tree.nodeData(n).node,
|
|
957
950
|
.anyframe_type => n = tree.nodeData(n).token_and_node[1],
|
|
958
951
|
|
|
959
952
|
.switch_case_one,
|
|
@@ -2111,9 +2104,7 @@ fn fullFnProtoComponents(tree: Ast, info: full.FnProto.Components) full.FnProto
|
|
|
2111
2104
|
|
|
2112
2105
|
fn fullPtrTypeComponents(tree: Ast, info: full.PtrType.Components) full.PtrType {
|
|
2113
2106
|
const size: std.builtin.Type.Pointer.Size = switch (tree.tokenTag(info.main_token)) {
|
|
2114
|
-
.asterisk,
|
|
2115
|
-
.asterisk_asterisk,
|
|
2116
|
-
=> .one,
|
|
2107
|
+
.asterisk => .one,
|
|
2117
2108
|
.l_bracket => switch (tree.tokenTag(info.main_token + 1)) {
|
|
2118
2109
|
.asterisk => if (tree.tokenTag(info.main_token + 2) == .identifier) .c else .many,
|
|
2119
2110
|
else => .slice,
|
|
@@ -2842,7 +2833,6 @@ pub const Error = struct {
|
|
|
2842
2833
|
} = .{ .none = {} },
|
|
2843
2834
|
|
|
2844
2835
|
pub const Tag = enum {
|
|
2845
|
-
asterisk_after_ptr_deref,
|
|
2846
2836
|
chained_comparison_operators,
|
|
2847
2837
|
decl_between_fields,
|
|
2848
2838
|
expected_block,
|
|
@@ -3059,11 +3049,8 @@ pub const Node = struct {
|
|
|
3059
3049
|
/// a `assign_destructure` node or a parsing error occured.
|
|
3060
3050
|
aligned_var_decl,
|
|
3061
3051
|
/// `errdefer expr`,
|
|
3062
|
-
/// `errdefer |payload| expr`.
|
|
3063
3052
|
///
|
|
3064
|
-
/// The `data` field is a `.
|
|
3065
|
-
/// 1. a `OptionalTokenIndex` to the payload identifier, if any.
|
|
3066
|
-
/// 2. a `Node.Index` to the deferred expression.
|
|
3053
|
+
/// The `data` field is a `.node` to the deferred expression.
|
|
3067
3054
|
///
|
|
3068
3055
|
/// The `main_token` field is the `errdefer` token.
|
|
3069
3056
|
@"errdefer",
|
|
@@ -3071,7 +3058,7 @@ pub const Node = struct {
|
|
|
3071
3058
|
///
|
|
3072
3059
|
/// The `data` field is a `.node` to the deferred expression.
|
|
3073
3060
|
///
|
|
3074
|
-
/// The `main_token` field is the `defer
|
|
3061
|
+
/// The `main_token` field is the `defer` token.
|
|
3075
3062
|
@"defer",
|
|
3076
3063
|
/// `lhs catch rhs`,
|
|
3077
3064
|
/// `lhs catch |err| rhs`.
|
|
@@ -3181,8 +3168,6 @@ pub const Node = struct {
|
|
|
3181
3168
|
div,
|
|
3182
3169
|
/// `lhs % rhs`. The `main_token` field is the `%` token.
|
|
3183
3170
|
mod,
|
|
3184
|
-
/// `lhs ** rhs`. The `main_token` field is the `**` token.
|
|
3185
|
-
array_mult,
|
|
3186
3171
|
/// `lhs *% rhs`. The `main_token` field is the `*%` token.
|
|
3187
3172
|
mul_wrap,
|
|
3188
3173
|
/// `lhs *| rhs`. The `main_token` field is the `*|` token.
|
|
@@ -3253,8 +3238,6 @@ pub const Node = struct {
|
|
|
3253
3238
|
///
|
|
3254
3239
|
/// The `main_token` is the asterisk if a single item pointer or the
|
|
3255
3240
|
/// lbracket if a slice, many-item pointer, or C-pointer.
|
|
3256
|
-
/// The `main_token` might be a ** token, which is shared with a
|
|
3257
|
-
/// parent/child pointer type and may require special handling.
|
|
3258
3241
|
ptr_type_aligned,
|
|
3259
3242
|
/// `[*:lhs]rhs`,
|
|
3260
3243
|
/// `*rhs`,
|
|
@@ -3266,8 +3249,6 @@ pub const Node = struct {
|
|
|
3266
3249
|
///
|
|
3267
3250
|
/// The `main_token` is the asterisk if a single item pointer or the
|
|
3268
3251
|
/// lbracket if a slice, many-item pointer, or C-pointer.
|
|
3269
|
-
/// The `main_token` might be a ** token, which is shared with a
|
|
3270
|
-
/// parent/child pointer type and may require special handling.
|
|
3271
3252
|
ptr_type_sentinel,
|
|
3272
3253
|
/// The `data` field is a `.extra_and_node`:
|
|
3273
3254
|
/// 1. a `ExtraIndex` to `PtrType`.
|
|
@@ -3275,8 +3256,6 @@ pub const Node = struct {
|
|
|
3275
3256
|
///
|
|
3276
3257
|
/// The `main_token` is the asterisk if a single item pointer or the
|
|
3277
3258
|
/// lbracket if a slice, many-item pointer, or C-pointer.
|
|
3278
|
-
/// The `main_token` might be a ** token, which is shared with a
|
|
3279
|
-
/// parent/child pointer type and may require special handling.
|
|
3280
3259
|
ptr_type,
|
|
3281
3260
|
/// The `data` field is a `.extra_and_node`:
|
|
3282
3261
|
/// 1. a `ExtraIndex` to `PtrTypeBitRange`.
|
|
@@ -3284,8 +3263,6 @@ pub const Node = struct {
|
|
|
3284
3263
|
///
|
|
3285
3264
|
/// The `main_token` is the asterisk if a single item pointer or the
|
|
3286
3265
|
/// lbracket if a slice, many-item pointer, or C-pointer.
|
|
3287
|
-
/// The `main_token` might be a ** token, which is shared with a
|
|
3288
|
-
/// parent/child pointer type and may require special handling.
|
|
3289
3266
|
ptr_type_bit_range,
|
|
3290
3267
|
/// `lhs[rhs..]`
|
|
3291
3268
|
///
|