@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.
Files changed (106) hide show
  1. package/compiler/build_runner.zig +1 -1
  2. package/compiler/reduce/Walk.zig +1 -6
  3. package/compiler/resinator/cvtres.zig +4 -4
  4. package/compiler/resinator/ico.zig +4 -4
  5. package/compiler/resinator/parse.zig +2 -2
  6. package/compiler/resinator/res.zig +1 -1
  7. package/compiler/translate-c/ast.zig +11 -21
  8. package/compiler_rt/atomics.zig +1 -1
  9. package/compiler_rt/ssp.zig +2 -2
  10. package/docs/wasm/Walk.zig +1 -3
  11. package/docs/wasm/html_render.zig +1 -2
  12. package/package.json +1 -1
  13. package/std/Io/Reader.zig +0 -5
  14. package/std/Io/Threaded.zig +4 -4
  15. package/std/Io/Writer.zig +1 -2
  16. package/std/Io/net/HostName.zig +11 -6
  17. package/std/Random/ChaCha.zig +2 -2
  18. package/std/Random/benchmark.zig +2 -2
  19. package/std/Thread.zig +2 -2
  20. package/std/base64.zig +5 -5
  21. package/std/bit_set.zig +7 -7
  22. package/std/c.zig +17 -17
  23. package/std/compress/flate/Decompress.zig +1 -1
  24. package/std/crypto/25519/curve25519.zig +2 -2
  25. package/std/crypto/25519/edwards25519.zig +3 -3
  26. package/std/crypto/25519/ristretto255.zig +2 -2
  27. package/std/crypto/25519/scalar.zig +6 -6
  28. package/std/crypto/25519/x25519.zig +1 -1
  29. package/std/crypto/Certificate.zig +1 -1
  30. package/std/crypto/Sha1.zig +1 -1
  31. package/std/crypto/aegis.zig +45 -39
  32. package/std/crypto/aes_ccm.zig +20 -20
  33. package/std/crypto/aes_gcm.zig +10 -12
  34. package/std/crypto/aes_ocb.zig +9 -9
  35. package/std/crypto/argon2.zig +15 -15
  36. package/std/crypto/bcrypt.zig +20 -10
  37. package/std/crypto/benchmark.zig +7 -7
  38. package/std/crypto/blake2.zig +100 -64
  39. package/std/crypto/cbc_mac.zig +1 -1
  40. package/std/crypto/chacha20.zig +10 -10
  41. package/std/crypto/cmac.zig +2 -2
  42. package/std/crypto/codecs/asn1.zig +1 -1
  43. package/std/crypto/ecdsa.zig +9 -9
  44. package/std/crypto/ff.zig +2 -2
  45. package/std/crypto/ghash_polyval.zig +4 -4
  46. package/std/crypto/hkdf.zig +1 -1
  47. package/std/crypto/isap.zig +3 -3
  48. package/std/crypto/kangarootwelve.zig +1 -1
  49. package/std/crypto/keccak_p.zig +7 -7
  50. package/std/crypto/md5.zig +1 -1
  51. package/std/crypto/ml_dsa.zig +33 -33
  52. package/std/crypto/ml_kem.zig +4 -4
  53. package/std/crypto/modes.zig +1 -1
  54. package/std/crypto/pbkdf2.zig +1 -1
  55. package/std/crypto/pcurves/p256/scalar.zig +3 -3
  56. package/std/crypto/pcurves/p384/scalar.zig +2 -2
  57. package/std/crypto/pcurves/secp256k1/scalar.zig +3 -3
  58. package/std/crypto/pcurves/tests/p256.zig +5 -5
  59. package/std/crypto/pcurves/tests/p384.zig +5 -5
  60. package/std/crypto/pcurves/tests/secp256k1.zig +3 -3
  61. package/std/crypto/salsa20.zig +8 -8
  62. package/std/crypto/sha2.zig +2 -2
  63. package/std/crypto/sha3.zig +2 -2
  64. package/std/crypto/siphash.zig +1 -1
  65. package/std/crypto/timing_safe.zig +5 -4
  66. package/std/crypto/tls/Client.zig +10 -9
  67. package/std/crypto.zig +3 -3
  68. package/std/debug/Dwarf.zig +1 -1
  69. package/std/debug.zig +6 -4
  70. package/std/elf.zig +1 -1
  71. package/std/enums.zig +1 -1
  72. package/std/fmt/parse_float/decimal.zig +1 -1
  73. package/std/fmt.zig +5 -1
  74. package/std/hash/Adler32.zig +3 -3
  75. package/std/hash/benchmark.zig +2 -2
  76. package/std/hash/wyhash.zig +1 -1
  77. package/std/heap/debug_allocator.zig +1 -1
  78. package/std/http.zig +1 -1
  79. package/std/json/static.zig +2 -2
  80. package/std/math/big/int.zig +3 -3
  81. package/std/math/nextafter.zig +1 -2
  82. package/std/math/powi.zig +2 -3
  83. package/std/math/signbit.zig +0 -1
  84. package/std/math.zig +12 -18
  85. package/std/mem.zig +9 -8
  86. package/std/meta.zig +1 -1
  87. package/std/os/emscripten.zig +2 -2
  88. package/std/os/linux.zig +4 -4
  89. package/std/os/uefi/hii.zig +1 -1
  90. package/std/tar/Writer.zig +39 -33
  91. package/std/tar.zig +8 -4
  92. package/std/unicode.zig +13 -8
  93. package/std/zig/Ast/Render.zig +1 -25
  94. package/std/zig/Ast.zig +5 -28
  95. package/std/zig/AstGen.zig +75 -184
  96. package/std/zig/AstRlAnnotate.zig +1 -11
  97. package/std/zig/AstSmith.zig +5 -11
  98. package/std/zig/LibCInstallation.zig +1 -1
  99. package/std/zig/Parse.zig +4 -69
  100. package/std/zig/TokenSmith.zig +0 -6
  101. package/std/zig/WindowsSdk.zig +1 -1
  102. package/std/zig/Zir.zig +0 -54
  103. package/std/zig/ZonGen.zig +0 -1
  104. package/std/zig/llvm/Builder.zig +3 -7
  105. package/std/zig/tokenizer.zig +4 -43
  106. package/std/zig.zig +0 -2
@@ -100,7 +100,7 @@ test "p384 public key is the neutral element (public verification)" {
100
100
  }
101
101
 
102
102
  test "p384 field element non-canonical encoding" {
103
- const s = [_]u8{0xff} ** 48;
103
+ const s: [48]u8 = @splat(0xff);
104
104
  try testing.expectError(error.NonCanonical, P384.Fe.fromBytes(s, .little));
105
105
  }
106
106
 
@@ -113,8 +113,8 @@ test "p384 neutral element decoding" {
113
113
  test "p384 double base multiplication" {
114
114
  const p1 = P384.basePoint;
115
115
  const p2 = P384.basePoint.dbl();
116
- const s1 = [_]u8{0x01} ** 48;
117
- const s2 = [_]u8{0x02} ** 48;
116
+ const s1: [48]u8 = @splat(0x01);
117
+ const s2: [48]u8 = @splat(0x02);
118
118
  const pr1 = try P384.mulDoubleBasePublic(p1, s1, p2, s2, .little);
119
119
  const pr2 = (try p1.mul(s1, .little)).add(try p2.mul(s2, .little));
120
120
  try testing.expect(pr1.equivalent(pr2));
@@ -123,8 +123,8 @@ test "p384 double base multiplication" {
123
123
  test "p384 double base multiplication with large scalars" {
124
124
  const p1 = P384.basePoint;
125
125
  const p2 = P384.basePoint.dbl();
126
- const s1 = [_]u8{0xee} ** 48;
127
- const s2 = [_]u8{0xdd} ** 48;
126
+ const s1: [48]u8 = @splat(0xee);
127
+ const s2: [48]u8 = @splat(0xdd);
128
128
  const pr1 = try P384.mulDoubleBasePublic(p1, s1, p2, s2, .little);
129
129
  const pr2 = (try p1.mul(s1, .little)).add(try p2.mul(s2, .little));
130
130
  try testing.expect(pr1.equivalent(pr2));
@@ -109,7 +109,7 @@ test "secp256k1 public key is the neutral element (public verification)" {
109
109
  }
110
110
 
111
111
  test "secp256k1 field element non-canonical encoding" {
112
- const s = [_]u8{0xff} ** 32;
112
+ const s: [32]u8 = @splat(0xff);
113
113
  try testing.expectError(error.NonCanonical, Secp256k1.Fe.fromBytes(s, .little));
114
114
  }
115
115
 
@@ -122,8 +122,8 @@ test "secp256k1 neutral element decoding" {
122
122
  test "secp256k1 double base multiplication" {
123
123
  const p1 = Secp256k1.basePoint;
124
124
  const p2 = Secp256k1.basePoint.dbl();
125
- const s1 = [_]u8{0x01} ** 32;
126
- const s2 = [_]u8{0x02} ** 32;
125
+ const s1: [32]u8 = @splat(0x01);
126
+ const s2: [32]u8 = @splat(0x02);
127
127
  const pr1 = try Secp256k1.mulDoubleBasePublic(p1, s1, p2, s2, .little);
128
128
  const pr2 = (try p1.mul(s1, .little)).add(try p2.mul(s2, .little));
129
129
  try testing.expect(pr1.equivalent(pr2));
@@ -384,7 +384,7 @@ pub const XSalsa20Poly1305 = struct {
384
384
  pub fn encrypt(c: []u8, tag: *[tag_length]u8, m: []const u8, ad: []const u8, npub: [nonce_length]u8, k: [key_length]u8) void {
385
385
  debug.assert(c.len == m.len);
386
386
  const extended = extend(rounds, k, npub);
387
- var block0 = [_]u8{0} ** 64;
387
+ var block0: [64]u8 = @splat(0);
388
388
  const mlen0 = @min(32, m.len);
389
389
  @memcpy(block0[32..][0..mlen0], m[0..mlen0]);
390
390
  Salsa20.xor(block0[0..], block0[0..], 0, extended.key, extended.nonce);
@@ -408,7 +408,7 @@ pub const XSalsa20Poly1305 = struct {
408
408
  pub fn decrypt(m: []u8, c: []const u8, tag: [tag_length]u8, ad: []const u8, npub: [nonce_length]u8, k: [key_length]u8) AuthenticationError!void {
409
409
  debug.assert(c.len == m.len);
410
410
  const extended = extend(rounds, k, npub);
411
- var block0 = [_]u8{0} ** 64;
411
+ var block0: [64]u8 = @splat(0);
412
412
  const mlen0 = @min(32, c.len);
413
413
  @memcpy(block0[32..][0..mlen0], c[0..mlen0]);
414
414
  Salsa20.xor(block0[0..], block0[0..], 0, extended.key, extended.nonce);
@@ -489,7 +489,7 @@ pub const Box = struct {
489
489
  /// Compute a secret suitable for `secretbox` given a recipient's public key and a sender's secret key.
490
490
  pub fn createSharedSecret(public_key: [public_length]u8, secret_key: [secret_length]u8) (IdentityElementError || WeakPublicKeyError)![shared_length]u8 {
491
491
  const p = try X25519.scalarmult(secret_key, public_key);
492
- const zero = [_]u8{0} ** 16;
492
+ const zero: [16]u8 = @splat(0);
493
493
  return SalsaImpl(20).hsalsa(zero, p);
494
494
  }
495
495
 
@@ -559,15 +559,15 @@ const htest = @import("test.zig");
559
559
  test "(x)salsa20" {
560
560
  if (builtin.cpu.has(.riscv, .v) and builtin.zig_backend == .stage2_llvm) return error.SkipZigTest; // https://github.com/ziglang/zig/issues/24299
561
561
 
562
- const key = [_]u8{0x69} ** 32;
563
- const nonce = [_]u8{0x42} ** 8;
564
- const msg = [_]u8{0} ** 20;
562
+ const key: [32]u8 = @splat(0x69);
563
+ const nonce: [8]u8 = @splat(0x42);
564
+ const msg: [20]u8 = @splat(0);
565
565
  var c: [msg.len]u8 = undefined;
566
566
 
567
567
  Salsa20.xor(&c, msg[0..], 0, key, nonce);
568
568
  try htest.assertEqual("30ff9933aa6534ff5207142593cd1fca4b23bdd8", c[0..]);
569
569
 
570
- const extended_nonce = [_]u8{0x42} ** 24;
570
+ const extended_nonce: [24]u8 = @splat(0x42);
571
571
  XSalsa20.xor(&c, msg[0..], 0, key, extended_nonce);
572
572
  try htest.assertEqual("b4ab7d82e750ec07644fa3281bce6cd91d4243f9", c[0..]);
573
573
  }
@@ -637,7 +637,7 @@ test "xsalsa20poly1305 sealedbox" {
637
637
  test "secretbox twoblocks" {
638
638
  const key = [_]u8{ 0xc9, 0xc9, 0x4d, 0xcf, 0x68, 0xbe, 0x00, 0xe4, 0x7f, 0xe6, 0x13, 0x26, 0xfc, 0xc4, 0x2f, 0xd0, 0xdb, 0x93, 0x91, 0x1c, 0x09, 0x94, 0x89, 0xe1, 0x1b, 0x88, 0x63, 0x18, 0x86, 0x64, 0x8b, 0x7b };
639
639
  const nonce = [_]u8{ 0xa4, 0x33, 0xe9, 0x0a, 0x07, 0x68, 0x6e, 0x9a, 0x2b, 0x6d, 0xd4, 0x59, 0x04, 0x72, 0x3e, 0xd3, 0x8a, 0x67, 0x55, 0xc7, 0x9e, 0x3e, 0x77, 0xdc };
640
- const msg = [_]u8{'a'} ** 97;
640
+ const msg: [97]u8 = @splat('a');
641
641
  var ciphertext: [msg.len + SecretBox.tag_length]u8 = undefined;
642
642
  SecretBox.seal(&ciphertext, &msg, nonce, key);
643
643
  try htest.assertEqual("b05760e217288ba079caa2fd57fd3701784974ffcfda20fe523b89211ad8af065a6eb37cdb29d51aca5bd75dafdd21d18b044c54bb7c526cf576c94ee8900f911ceab0147e82b667a28c52d58ceb29554ff45471224d37b03256b01c119b89ff6d36855de8138d103386dbc9d971f52261", &ciphertext);
@@ -461,7 +461,7 @@ test "sha256 streaming" {
461
461
  }
462
462
 
463
463
  test "sha256 aligned final" {
464
- var block = [_]u8{0} ** Sha256.block_length;
464
+ var block: [Sha256.block_length]u8 = @splat(0);
465
465
  var out: [Sha256.digest_length]u8 = undefined;
466
466
 
467
467
  var h = Sha256.init(.{});
@@ -833,7 +833,7 @@ test "sha512 streaming" {
833
833
  }
834
834
 
835
835
  test "sha512 aligned final" {
836
- var block = [_]u8{0} ** Sha512.block_length;
836
+ var block: [Sha512.block_length]u8 = @splat(0);
837
837
  var out: [Sha512.digest_length]u8 = undefined;
838
838
 
839
839
  var h = Sha512.init(.{});
@@ -543,7 +543,7 @@ test "sha3-256 streaming" {
543
543
  }
544
544
 
545
545
  test "sha3-256 aligned final" {
546
- var block = [_]u8{0} ** Sha3_256.block_length;
546
+ var block: [Sha3_256.block_length]u8 = @splat(0);
547
547
  var out: [Sha3_256.digest_length]u8 = undefined;
548
548
 
549
549
  var h = Sha3_256.init(.{});
@@ -616,7 +616,7 @@ test "sha3-512 streaming" {
616
616
  }
617
617
 
618
618
  test "sha3-512 aligned final" {
619
- var block = [_]u8{0} ** Sha3_512.block_length;
619
+ var block: [Sha3_512.block_length]u8 = @splat(0);
620
620
  var out: [Sha3_512.digest_length]u8 = undefined;
621
621
 
622
622
  var h = Sha3_512.init(.{});
@@ -91,7 +91,7 @@ fn SipHashStateless(comptime T: type, comptime c_rounds: usize, comptime d_round
91
91
 
92
92
  self.msg_len +%= @as(u8, @truncate(b.len));
93
93
 
94
- var buf = [_]u8{0} ** 8;
94
+ var buf: [8]u8 = @splat(0);
95
95
  @memcpy(buf[0..b.len], b);
96
96
  buf[7] = self.msg_len;
97
97
  self.round(buf);
@@ -207,8 +207,8 @@ test "eql (vectors)" {
207
207
 
208
208
  test compare {
209
209
  const expectEqual = std.testing.expectEqual;
210
- var a = [_]u8{10} ** 32;
211
- var b = [_]u8{10} ** 32;
210
+ var a: [32]u8 = @splat(10);
211
+ var b: [32]u8 = @splat(10);
212
212
  try expectEqual(compare(u8, &a, &b, .big), .eq);
213
213
  try expectEqual(compare(u8, &a, &b, .little), .eq);
214
214
  a[31] = 1;
@@ -228,7 +228,7 @@ test "add and sub" {
228
228
  var a: [len]u8 = undefined;
229
229
  var b: [len]u8 = undefined;
230
230
  var c: [len]u8 = undefined;
231
- const zero = [_]u8{0} ** len;
231
+ const zero: [len]u8 = @splat(0);
232
232
  var iterations: usize = 100;
233
233
  while (iterations != 0) : (iterations -= 1) {
234
234
  io.random(&a);
@@ -262,7 +262,8 @@ test classify {
262
262
  declassify(&out);
263
263
 
264
264
  // Comparing public data in non-constant time is acceptable.
265
- try expect(!std.mem.eql(u8, &out, &[_]u8{0} ** out.len));
265
+ const zeroes: [out.len]u8 = @splat(0);
266
+ try expect(!std.mem.eql(u8, &out, &zeroes));
266
267
 
267
268
  // Comparing secret data must be done in constant time. The result
268
269
  // is going to be considered as secret as well.
@@ -375,7 +375,7 @@ pub fn init(input: *Reader, output: *Writer, options: Options) InitError!Client
375
375
  const auth_tag = record_decoder.array(P.AEAD.tag_length).*;
376
376
  const nonce = nonce: {
377
377
  const V = @Vector(P.AEAD.nonce_length, u8);
378
- const pad = [1]u8{0} ** (P.AEAD.nonce_length - 8);
378
+ const pad: [P.AEAD.nonce_length - 8]u8 = @splat(0);
379
379
  const operand: V = pad ++ @as([8]u8, @bitCast(big(read_seq)));
380
380
  break :nonce @as(V, pv.server_handshake_iv) ^ operand;
381
381
  };
@@ -415,7 +415,7 @@ pub fn init(input: *Reader, output: *Writer, options: Options) InitError!Client
415
415
  comptime std.math.shl(u64, std.math.maxInt(u64), 8 * P.record_iv_length);
416
416
  const nonce: [P.AEAD.nonce_length]u8 = nonce: {
417
417
  const V = @Vector(P.AEAD.nonce_length, u8);
418
- const pad = [1]u8{0} ** (P.AEAD.nonce_length - 8);
418
+ const pad: [P.AEAD.nonce_length - 8]u8 = @splat(0);
419
419
  const operand: V = pad ++ @as([8]u8, @bitCast(big(masked_read_seq)));
420
420
  break :nonce @as(V, pv.app_cipher.server_write_IV ++ record_iv) ^ operand;
421
421
  };
@@ -539,7 +539,7 @@ pub fn init(input: *Reader, output: *Writer, options: Options) InitError!Client
539
539
  const p = &@field(handshake_cipher, @tagName(tag.with()));
540
540
  const P = @TypeOf(p.*).A;
541
541
  const hello_hash = p.transcript_hash.peek();
542
- const zeroes = [1]u8{0} ** P.Hash.digest_length;
542
+ const zeroes: [P.Hash.digest_length]u8 = @splat(0);
543
543
  const early_secret = P.Hkdf.extract(&[1]u8{0}, &zeroes);
544
544
  const empty_hash = tls.emptyHash(P.Hash);
545
545
  p.version = .{ .tls_1_3 = undefined };
@@ -791,7 +791,7 @@ pub fn init(input: *Reader, output: *Writer, options: Options) InitError!Client
791
791
  const pv = &p.version.tls_1_2;
792
792
  const nonce: [P.AEAD.nonce_length]u8 = nonce: {
793
793
  const V = @Vector(P.AEAD.nonce_length, u8);
794
- const pad = [1]u8{0} ** (P.AEAD.nonce_length - 8);
794
+ const pad: [P.AEAD.nonce_length - 8]u8 = @splat(0);
795
795
  const operand: V = pad ++ @as([8]u8, @bitCast(big(write_seq)));
796
796
  break :nonce @as(V, pv.app_cipher.client_write_IV ++ pv.app_cipher.client_salt) ^ operand;
797
797
  };
@@ -832,8 +832,9 @@ pub fn init(input: *Reader, output: *Writer, options: Options) InitError!Client
832
832
  }
833
833
  switch (handshake_cipher) {
834
834
  inline else => |*p| {
835
+ const pad: [64]u8 = @splat(' ');
835
836
  try main_cert_pub_key.verifySignature(&hsd, &.{
836
- " " ** 64 ++ "TLS 1.3, server CertificateVerify\x00",
837
+ pad ++ "TLS 1.3, server CertificateVerify\x00",
837
838
  &p.transcript_hash.peek(),
838
839
  });
839
840
  p.transcript_hash.update(wrapped_handshake);
@@ -1066,7 +1067,7 @@ fn prepareCiphertextRecord(
1066
1067
  ciphertext_end += auth_tag.len;
1067
1068
  const nonce = nonce: {
1068
1069
  const V = @Vector(P.AEAD.nonce_length, u8);
1069
- const pad = [1]u8{0} ** (P.AEAD.nonce_length - 8);
1070
+ const pad: [P.AEAD.nonce_length - 8]u8 = @splat(0);
1070
1071
  const operand: V = pad ++ mem.toBytes(big(c.write_seq));
1071
1072
  break :nonce @as(V, pv.client_iv) ^ operand;
1072
1073
  };
@@ -1103,7 +1104,7 @@ fn prepareCiphertextRecord(
1103
1104
  ciphertext_end += P.record_iv_length;
1104
1105
  const nonce: [P.AEAD.nonce_length]u8 = nonce: {
1105
1106
  const V = @Vector(P.AEAD.nonce_length, u8);
1106
- const pad = [1]u8{0} ** (P.AEAD.nonce_length - 8);
1107
+ const pad: [P.AEAD.nonce_length - 8]u8 = @splat(0);
1107
1108
  const operand: V = pad ++ @as([8]u8, @bitCast(big(c.write_seq)));
1108
1109
  break :nonce @as(V, pv.client_write_IV ++ pv.client_salt) ^ operand;
1109
1110
  };
@@ -1185,7 +1186,7 @@ fn readIndirect(c: *Client) Reader.Error!usize {
1185
1186
  const auth_tag = (input.takeArray(P.AEAD.tag_length) catch unreachable).*; // already peeked
1186
1187
  const nonce = nonce: {
1187
1188
  const V = @Vector(P.AEAD.nonce_length, u8);
1188
- const pad = [1]u8{0} ** (P.AEAD.nonce_length - 8);
1189
+ const pad: [P.AEAD.nonce_length - 8]u8 = @splat(0);
1189
1190
  const operand: V = pad ++ mem.toBytes(big(c.read_seq));
1190
1191
  break :nonce @as(V, pv.server_iv) ^ operand;
1191
1192
  };
@@ -1211,7 +1212,7 @@ fn readIndirect(c: *Client) Reader.Error!usize {
1211
1212
  comptime std.math.shl(u64, std.math.maxInt(u64), 8 * P.record_iv_length);
1212
1213
  const nonce: [P.AEAD.nonce_length]u8 = nonce: {
1213
1214
  const V = @Vector(P.AEAD.nonce_length, u8);
1214
- const pad = [1]u8{0} ** (P.AEAD.nonce_length - 8);
1215
+ const pad: [P.AEAD.nonce_length - 8]u8 = @splat(0);
1215
1216
  const operand: V = pad ++ @as([8]u8, @bitCast(big(masked_read_seq)));
1216
1217
  break :nonce @as(V, pv.server_write_IV ++ record_iv) ^ operand;
1217
1218
  };
package/std/crypto.zig CHANGED
@@ -394,7 +394,7 @@ test "issue #4532: no index out of bounds" {
394
394
  };
395
395
 
396
396
  inline for (types) |Hasher| {
397
- var block = [_]u8{'#'} ** Hasher.block_length;
397
+ var block: [Hasher.block_length]u8 = @splat('#');
398
398
  var out1: [Hasher.digest_length]u8 = undefined;
399
399
  var out2: [Hasher.digest_length]u8 = undefined;
400
400
  const h0 = Hasher.init(.{});
@@ -417,8 +417,8 @@ pub fn secureZero(comptime T: type, s: []volatile T) void {
417
417
  }
418
418
 
419
419
  test secureZero {
420
- var a = [_]u8{0xfe} ** 8;
421
- var b = [_]u8{0xfe} ** 8;
420
+ var a: [8]u8 = @splat(0xFE);
421
+ var b: [8]u8 = @splat(0xFE);
422
422
 
423
423
  @memset(&a, 0);
424
424
  secureZero(u8, &b);
@@ -1346,7 +1346,7 @@ const FileEntry = struct {
1346
1346
  dir_index: u32 = 0,
1347
1347
  mtime: u64 = 0,
1348
1348
  size: u64 = 0,
1349
- md5: [16]u8 = [1]u8{0} ** 16,
1349
+ md5: [16]u8 = @splat(0),
1350
1350
  };
1351
1351
 
1352
1352
  const LineNumberProgram = struct {
package/std/debug.zig CHANGED
@@ -1381,7 +1381,7 @@ test printLineFromFile {
1381
1381
  try writer.flush();
1382
1382
 
1383
1383
  try printLineFromFile(io, output_stream, .{ .file_name = path, .line = 2, .column = 0 });
1384
- try expectEqualStrings(("a" ** overlap) ++ "\n", aw.written());
1384
+ try expectEqualStrings(&@as([overlap]u8, @splat('a')) ++ "\n", aw.written());
1385
1385
  aw.clearRetainingCapacity();
1386
1386
  }
1387
1387
  {
@@ -1395,7 +1395,7 @@ test printLineFromFile {
1395
1395
  try writer.splatByteAll('a', std.heap.page_size_max);
1396
1396
 
1397
1397
  try printLineFromFile(io, output_stream, .{ .file_name = path, .line = 1, .column = 0 });
1398
- try expectEqualStrings(("a" ** std.heap.page_size_max) ++ "\n", aw.written());
1398
+ try expectEqualStrings(&@as([std.heap.page_size_max]u8, @splat('a')) ++ "\n", aw.written());
1399
1399
  aw.clearRetainingCapacity();
1400
1400
  }
1401
1401
  {
@@ -1410,14 +1410,16 @@ test printLineFromFile {
1410
1410
 
1411
1411
  try expectError(error.EndOfStream, printLineFromFile(io, output_stream, .{ .file_name = path, .line = 2, .column = 0 }));
1412
1412
 
1413
+ const many_a: [3 * std.heap.page_size_max]u8 = @splat('a');
1414
+
1413
1415
  try printLineFromFile(io, output_stream, .{ .file_name = path, .line = 1, .column = 0 });
1414
- try expectEqualStrings(("a" ** (3 * std.heap.page_size_max)) ++ "\n", aw.written());
1416
+ try expectEqualStrings(&many_a ++ "\n", aw.written());
1415
1417
  aw.clearRetainingCapacity();
1416
1418
 
1417
1419
  try writer.writeAll("a\na");
1418
1420
 
1419
1421
  try printLineFromFile(io, output_stream, .{ .file_name = path, .line = 1, .column = 0 });
1420
- try expectEqualStrings(("a" ** (3 * std.heap.page_size_max)) ++ "a\n", aw.written());
1422
+ try expectEqualStrings(&many_a ++ "a\n", aw.written());
1421
1423
  aw.clearRetainingCapacity();
1422
1424
 
1423
1425
  try printLineFromFile(io, output_stream, .{ .file_name = path, .line = 2, .column = 0 });
package/std/elf.zig CHANGED
@@ -3054,7 +3054,7 @@ pub const ar_hdr = extern struct {
3054
3054
  fn genSpecialMemberName(comptime name: []const u8) *const [16]u8 {
3055
3055
  assert(name.len <= 16);
3056
3056
  const padding = 16 - name.len;
3057
- return name ++ &[_]u8{0x20} ** padding;
3057
+ return name ++ @as([padding]u8, @splat(0x20));
3058
3058
  }
3059
3059
 
3060
3060
  // Archive files start with the ARMAG identifying string. Then follows a
package/std/enums.zig CHANGED
@@ -166,7 +166,7 @@ pub fn directEnumArrayDefault(
166
166
  init_values: EnumFieldStruct(E, Data, default),
167
167
  ) [directEnumArrayLen(E, max_unused_slots)]Data {
168
168
  const len = comptime directEnumArrayLen(E, max_unused_slots);
169
- var result: [len]Data = if (default) |d| [_]Data{d} ** len else undefined;
169
+ var result: [len]Data = @splat(default orelse undefined);
170
170
  inline for (@typeInfo(@TypeOf(init_values)).@"struct".fields) |f| {
171
171
  const enum_value = @field(E, f.name);
172
172
  const index = @as(usize, @intCast(@intFromEnum(enum_value)));
@@ -80,7 +80,7 @@ pub fn Decimal(comptime T: type) type {
80
80
  .num_digits = 0,
81
81
  .decimal_point = 0,
82
82
  .truncated = false,
83
- .digits = [_]u8{0} ** max_digits,
83
+ .digits = @splat(0),
84
84
  };
85
85
  }
86
86
 
package/std/fmt.zig CHANGED
@@ -1194,8 +1194,12 @@ test bytesToHex {
1194
1194
  }
1195
1195
 
1196
1196
  test hexToBytes {
1197
+ const repeated: []const u8 = repeated: {
1198
+ const buf: [32][2]u8 = @splat("90".*);
1199
+ break :repeated @ptrCast(&buf);
1200
+ };
1197
1201
  var buf: [32]u8 = undefined;
1198
- try expectFmt("90" ** 32, "{X}", .{try hexToBytes(&buf, "90" ** 32)});
1202
+ try expectFmt(repeated, "{X}", .{try hexToBytes(&buf, repeated)});
1199
1203
  try expectFmt("ABCD", "{X}", .{try hexToBytes(&buf, "ABCD")});
1200
1204
  try expectFmt("", "{X}", .{try hexToBytes(&buf, "")});
1201
1205
  try std.testing.expectError(error.InvalidCharacter, hexToBytes(&buf, "012Z"));
@@ -88,15 +88,15 @@ test "sanity" {
88
88
  }
89
89
 
90
90
  test "long" {
91
- const long1 = [_]u8{1} ** 1024;
91
+ const long1: [1024]u8 = @splat(1);
92
92
  try testing.expectEqual(@as(u32, 0x06780401), hash(long1[0..]));
93
93
 
94
- const long2 = [_]u8{1} ** 1025;
94
+ const long2: [1025]u8 = @splat(1);
95
95
  try testing.expectEqual(@as(u32, 0x0a7a0402), hash(long2[0..]));
96
96
  }
97
97
 
98
98
  test "very long" {
99
- const long = [_]u8{1} ** 5553;
99
+ const long: [5553]u8 = @splat(1);
100
100
  try testing.expectEqual(@as(u32, 0x707f15b2), hash(long[0..]));
101
101
  }
102
102
 
@@ -93,13 +93,13 @@ const hashes = [_]Hash{
93
93
  .ty = hash.SipHash64(1, 3),
94
94
  .name = "siphash64",
95
95
  .has_crypto_api = true,
96
- .init_u8s = &[_]u8{0} ** 16,
96
+ .init_u8s = &@as([16]u8, @splat(0)),
97
97
  },
98
98
  Hash{
99
99
  .ty = hash.SipHash128(1, 3),
100
100
  .name = "siphash128",
101
101
  .has_crypto_api = true,
102
- .init_u8s = &[_]u8{0} ** 16,
102
+ .init_u8s = &@as([16]u8, @splat(0)),
103
103
  },
104
104
  };
105
105
 
@@ -253,7 +253,7 @@ test "iterative api" {
253
253
  }
254
254
 
255
255
  test "iterative maintains last sixteen" {
256
- const input = "Z" ** 48 ++ "01234567890abcdefg";
256
+ const input = &@as([48]u8, @splat('Z')) ++ "01234567890abcdefg";
257
257
  const seed = 0;
258
258
 
259
259
  for (0..17) |i| {
@@ -164,7 +164,7 @@ pub fn DebugAllocator(comptime config: Config) type {
164
164
  return struct {
165
165
  backing_allocator: Allocator = std.heap.page_allocator,
166
166
  /// Tracks the active bucket, which is the one that has free slots in it.
167
- buckets: [small_bucket_count]?*BucketHeader = [1]?*BucketHeader{null} ** small_bucket_count,
167
+ buckets: [small_bucket_count]?*BucketHeader = @splat(null),
168
168
  large_allocations: LargeAllocTable = .empty,
169
169
  total_requested_bytes: @TypeOf(total_requested_bytes_init) = total_requested_bytes_init,
170
170
  requested_memory_limit: @TypeOf(requested_memory_limit_init) = requested_memory_limit_init,
package/std/http.zig CHANGED
@@ -749,7 +749,7 @@ pub const BodyWriter = struct {
749
749
  /// How many zeroes to reserve for hex-encoded chunk length.
750
750
  const chunk_len_digits = 8;
751
751
  const max_chunk_len: usize = std.math.pow(u64, 16, chunk_len_digits) - 1;
752
- const chunk_header_template = ("0" ** chunk_len_digits) ++ "\r\n";
752
+ const chunk_header_template = @as([chunk_len_digits]u8, @splat('0')) ++ "\r\n";
753
753
 
754
754
  comptime {
755
755
  assert(max_chunk_len == std.math.maxInt(u32));
@@ -334,7 +334,7 @@ pub fn innerParse(
334
334
  if (.object_begin != try source.next()) return error.UnexpectedToken;
335
335
 
336
336
  var r: T = undefined;
337
- var fields_seen = [_]bool{false} ** structInfo.fields.len;
337
+ var fields_seen: [structInfo.fields.len]bool = @splat(false);
338
338
 
339
339
  while (true) {
340
340
  var name_token: ?Token = try source.nextAllocMax(allocator, .alloc_if_needed, options.max_value_len.?);
@@ -649,7 +649,7 @@ pub fn innerParseFromValue(
649
649
  if (source != .object) return error.UnexpectedToken;
650
650
 
651
651
  var r: T = undefined;
652
- var fields_seen = [_]bool{false} ** structInfo.fields.len;
652
+ var fields_seen: [structInfo.fields.len]bool = @splat(false);
653
653
 
654
654
  var it = source.object.iterator();
655
655
  while (it.next()) |kv| {
@@ -29,8 +29,8 @@ const Constants = struct {
29
29
  };
30
30
  const constants: Constants = blk: {
31
31
  @setEvalBranchQuota(2000);
32
- var digits_per_limb = [_]u8{0} ** 37;
33
- var bases = [_]Limb{0} ** 37;
32
+ var digits_per_limb: [37]u8 = @splat(0);
33
+ var bases: [37]Limb = @splat(0);
34
34
  for (2..37) |base| {
35
35
  digits_per_limb[base] = @intCast(math.log(Limb, base, math.maxInt(Limb)));
36
36
  bases[base] = std.math.pow(Limb, base, digits_per_limb[base]);
@@ -2391,7 +2391,7 @@ pub const Const = struct {
2391
2391
  var limbs: [calcToStringLimbsBufferLen(available_len, 10)]Limb = undefined;
2392
2392
 
2393
2393
  const biggest: Const = .{
2394
- .limbs = &([1]Limb{comptime math.maxInt(Limb)} ** available_len),
2394
+ .limbs = &@as([available_len]Limb, @splat(comptime math.maxInt(Limb))),
2395
2395
  .positive = false,
2396
2396
  };
2397
2397
  var buf: [biggest.sizeInBaseUpperBound(2)]u8 = undefined;
@@ -23,7 +23,7 @@ pub fn nextAfter(comptime T: type, x: T, y: T) T {
23
23
  fn nextAfterInt(comptime T: type, x: T, y: T) T {
24
24
  comptime assert(@typeInfo(T) == .int or @typeInfo(T) == .comptime_int);
25
25
  return if (@typeInfo(T) == .int and @bitSizeOf(T) < 2)
26
- // Special case for `i0`, `u0`, `i1`, and `u1`.
26
+ // Special case for `u0`, `i1`, and `u1`.
27
27
  y
28
28
  else if (y > x)
29
29
  x + 1
@@ -102,7 +102,6 @@ fn nextAfterFloat(comptime T: type, x: T, y: T) T {
102
102
  }
103
103
 
104
104
  test "int" {
105
- try expect(nextAfter(i0, 0, 0) == 0);
106
105
  try expect(nextAfter(u0, 0, 0) == 0);
107
106
  try expect(nextAfter(i1, 0, 0) == 0);
108
107
  try expect(nextAfter(i1, 0, -1) == -1);
package/std/math/powi.zig CHANGED
@@ -15,12 +15,12 @@ const testing = std.testing;
15
15
  /// - Underflow: Absolute value of result smaller than 1
16
16
  ///
17
17
  /// Edge case rules ordered by precedence:
18
- /// - powi(T, x, 0) = 1 unless T is i1, i0, u0
18
+ /// - powi(T, x, 0) = 1 unless T is i1, u0
19
19
  /// - powi(T, 0, x) = 0 when x > 0
20
20
  /// - powi(T, 0, x) = Overflow
21
21
  /// - powi(T, 1, y) = 1
22
22
  /// - powi(T, -1, y) = -1 for y an odd integer
23
- /// - powi(T, -1, y) = 1 unless T is i1, i0, u0
23
+ /// - powi(T, -1, y) = 1 unless T is i1, u0
24
24
  /// - powi(T, -1, y) = Overflow
25
25
  /// - powi(T, x, y) = Overflow when y >= @bitSizeOf(x)
26
26
  /// - powi(T, x, y) = Underflow when y < 0
@@ -189,7 +189,6 @@ test "powi.special" {
189
189
 
190
190
  test "powi.narrow" {
191
191
  try testing.expectError(error.Overflow, powi(u0, 0, 0));
192
- try testing.expectError(error.Overflow, powi(i0, 0, 0));
193
192
  try testing.expectError(error.Overflow, powi(i1, 0, 0));
194
193
  try testing.expectError(error.Overflow, powi(i1, -1, 0));
195
194
  try testing.expectError(error.Overflow, powi(i1, 0, -1));
@@ -13,7 +13,6 @@ pub fn signbit(x: anytype) bool {
13
13
  }
14
14
 
15
15
  test signbit {
16
- try testInts(i0);
17
16
  try testInts(u0);
18
17
  try testInts(i1);
19
18
  try testInts(u1);
package/std/math.zig CHANGED
@@ -1141,13 +1141,11 @@ test isPowerOfTwo {
1141
1141
  pub fn ByteAlignedInt(comptime T: type) type {
1142
1142
  const info = @typeInfo(T).int;
1143
1143
  const bits = (info.bits + 7) / 8 * 8;
1144
- const extended_type = std.meta.Int(info.signedness, bits);
1145
- return extended_type;
1144
+ return @Int(info.signedness, bits);
1146
1145
  }
1147
1146
 
1148
1147
  test ByteAlignedInt {
1149
1148
  try testing.expect(ByteAlignedInt(u0) == u0);
1150
- try testing.expect(ByteAlignedInt(i0) == i0);
1151
1149
  try testing.expect(ByteAlignedInt(u3) == u8);
1152
1150
  try testing.expect(ByteAlignedInt(u8) == u8);
1153
1151
  try testing.expect(ByteAlignedInt(i111) == i112);
@@ -1218,7 +1216,7 @@ pub fn ceilPowerOfTwoPromote(comptime T: type, value: T) std.meta.Int(@typeInfo(
1218
1216
  comptime assert(@typeInfo(T) == .int);
1219
1217
  comptime assert(@typeInfo(T).int.signedness == .unsigned);
1220
1218
  assert(value != 0);
1221
- const PromotedType = std.meta.Int(@typeInfo(T).int.signedness, @typeInfo(T).int.bits + 1);
1219
+ const PromotedType = @Int(@typeInfo(T).int.signedness, @typeInfo(T).int.bits + 1);
1222
1220
  const ShiftType = std.math.Log2Int(PromotedType);
1223
1221
  return @as(PromotedType, 1) << @as(ShiftType, @intCast(@typeInfo(T).int.bits - @clz(value - 1)));
1224
1222
  }
@@ -1230,7 +1228,7 @@ pub fn ceilPowerOfTwo(comptime T: type, value: T) (error{Overflow}!T) {
1230
1228
  comptime assert(@typeInfo(T) == .int);
1231
1229
  const info = @typeInfo(T).int;
1232
1230
  comptime assert(info.signedness == .unsigned);
1233
- const PromotedType = std.meta.Int(info.signedness, info.bits + 1);
1231
+ const PromotedType = @Int(info.signedness, info.bits + 1);
1234
1232
  const overflowBit = @as(PromotedType, 1) << info.bits;
1235
1233
  const x = ceilPowerOfTwoPromote(T, value);
1236
1234
  if (overflowBit & x != 0) {
@@ -1442,19 +1440,17 @@ test lerp {
1442
1440
 
1443
1441
  /// Returns the maximum value of integer type T.
1444
1442
  pub fn maxInt(comptime T: type) comptime_int {
1445
- const info = @typeInfo(T);
1446
- const bit_count = info.int.bits;
1447
- if (bit_count == 0) return 0;
1448
- return (1 << (bit_count - @intFromBool(info.int.signedness == .signed))) - 1;
1443
+ const info = @typeInfo(T).int;
1444
+ return (1 << (info.bits - @intFromBool(info.signedness == .signed))) - 1;
1449
1445
  }
1450
1446
 
1451
1447
  /// Returns the minimum value of integer type T.
1452
1448
  pub fn minInt(comptime T: type) comptime_int {
1453
- const info = @typeInfo(T);
1454
- const bit_count = info.int.bits;
1455
- if (info.int.signedness == .unsigned) return 0;
1456
- if (bit_count == 0) return 0;
1457
- return -(1 << (bit_count - 1));
1449
+ const info = @typeInfo(T).int;
1450
+ return switch (info.signedness) {
1451
+ .unsigned => 0,
1452
+ .signed => -(1 << (info.bits - 1)),
1453
+ };
1458
1454
  }
1459
1455
 
1460
1456
  test maxInt {
@@ -1466,7 +1462,6 @@ test maxInt {
1466
1462
  try testing.expect(maxInt(u64) == 18446744073709551615);
1467
1463
  try testing.expect(maxInt(u128) == 340282366920938463463374607431768211455);
1468
1464
 
1469
- try testing.expect(maxInt(i0) == 0);
1470
1465
  try testing.expect(maxInt(i1) == 0);
1471
1466
  try testing.expect(maxInt(i8) == 127);
1472
1467
  try testing.expect(maxInt(i16) == 32767);
@@ -1486,7 +1481,6 @@ test minInt {
1486
1481
  try testing.expect(minInt(u64) == 0);
1487
1482
  try testing.expect(minInt(u128) == 0);
1488
1483
 
1489
- try testing.expect(minInt(i0) == 0);
1490
1484
  try testing.expect(minInt(i1) == -1);
1491
1485
  try testing.expect(minInt(i8) == -128);
1492
1486
  try testing.expect(minInt(i16) == -32768);
@@ -1710,8 +1704,8 @@ pub inline fn boolMask(comptime MaskInt: type, value: bool) MaskInt {
1710
1704
  if (@typeInfo(MaskInt) != .int)
1711
1705
  @compileError("boolMask requires an integer mask type.");
1712
1706
 
1713
- if (MaskInt == u0 or MaskInt == i0)
1714
- @compileError("boolMask cannot convert to u0 or i0, they are too small.");
1707
+ if (MaskInt == u0)
1708
+ @compileError("boolMask cannot convert to u0, it is too small.");
1715
1709
 
1716
1710
  // The u1 and i1 cases tend to overflow,
1717
1711
  // so we special case them here.