From e8bbc687d7ca254de94c721aa664accff792d240 Mon Sep 17 00:00:00 2001 From: Eric Willigers Date: Wed, 7 Oct 2026 10:22:12 +1100 Subject: [PATCH] update to Zig 0.17.0 I used Claude for this PR --- .github/workflows/tests.yml | 2 +- .github/workflows/zig-fmt.yml | 2 +- docs/INSTALLATION.md | 2 +- exercises/practice/allergies/.docs/instructions.append.md | 2 +- exercises/practice/allergies/.meta/example.zig | 2 +- exercises/practice/anagram/.docs/instructions.append.md | 2 +- exercises/practice/anagram/.meta/example.zig | 2 +- .../practice/dnd-character/.docs/instructions.append.md | 4 ++-- exercises/practice/isogram/.approaches/introduction.md | 2 +- exercises/practice/isogram/.approaches/simd/content.md | 2 +- exercises/practice/pangram/.meta/example.zig | 2 +- .../practice/perfect-numbers/.docs/instructions.append.md | 4 ++-- exercises/practice/queen-attack/test_queen_attack.zig | 8 ++++---- generators/exercises/queen_attack.py | 8 ++++---- 14 files changed, 22 insertions(+), 22 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 51a59dad..21c09754 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -19,7 +19,7 @@ jobs: - name: Install Zig uses: mlugg/setup-zig@d1434d08867e3ee9daa34448df10607b98908d29 with: - version: 0.16.0 + version: 0.17.0 - name: Test exercises shell: bash diff --git a/.github/workflows/zig-fmt.yml b/.github/workflows/zig-fmt.yml index 4a63d96a..b6b45d71 100644 --- a/.github/workflows/zig-fmt.yml +++ b/.github/workflows/zig-fmt.yml @@ -12,7 +12,7 @@ jobs: - name: Install Zig uses: mlugg/setup-zig@d1434d08867e3ee9daa34448df10607b98908d29 with: - version: 0.16.0 + version: 0.17.0 - name: Check that Zig code is formatted run: | diff --git a/docs/INSTALLATION.md b/docs/INSTALLATION.md index 10f108e8..4c4c28a5 100644 --- a/docs/INSTALLATION.md +++ b/docs/INSTALLATION.md @@ -5,7 +5,7 @@ Fortunately, all of the popular installation methods are listed on the [Zig inst ## Zig version -Exercism currently supports Zig 0.16.0 (released on 2026-04-14) only. +Exercism uses Zig 0.17.0 (released on 2026-10-01). An exercise may be compatible with a different Zig version, but that isn't guaranteed. Zig has not yet reached version 1.0, and breaking changes are common. diff --git a/exercises/practice/allergies/.docs/instructions.append.md b/exercises/practice/allergies/.docs/instructions.append.md index 8d0e5c29..5e76e5dc 100644 --- a/exercises/practice/allergies/.docs/instructions.append.md +++ b/exercises/practice/allergies/.docs/instructions.append.md @@ -4,4 +4,4 @@ It may be helpful to look at the implementation of [`std.enums.EnumSet`][enumset]. -[enumset]: https://ziglang.org/documentation/0.16.0/std/#std.enums.EnumSet +[enumset]: https://ziglang.org/documentation/0.17.0/std/#std.enums.EnumSet diff --git a/exercises/practice/allergies/.meta/example.zig b/exercises/practice/allergies/.meta/example.zig index a4163b58..2d59689a 100644 --- a/exercises/practice/allergies/.meta/example.zig +++ b/exercises/practice/allergies/.meta/example.zig @@ -20,7 +20,7 @@ pub fn isAllergicTo(score: tag_type, allergen: Allergen) bool { } pub fn initAllergenSet(score: usize) EnumSet(Allergen) { - const len = @typeInfo(Allergen).@"enum".fields.len; + const len = @typeInfo(Allergen).@"enum".field_names.len; const bits = IntegerBitSet(len){ .mask = @as(tag_type, @truncate(score)) }; return .{ .bits = bits }; } diff --git a/exercises/practice/anagram/.docs/instructions.append.md b/exercises/practice/anagram/.docs/instructions.append.md index f6e5ba38..087a88f7 100644 --- a/exercises/practice/anagram/.docs/instructions.append.md +++ b/exercises/practice/anagram/.docs/instructions.append.md @@ -13,6 +13,6 @@ For more details on hash maps in Zig, see: - [Zighelp - Hash Maps][zighelp] - [Zig Standard Library - `buf_set.zig`][buf-set] -[buf-set]: https://ziglang.org/documentation/0.16.0/std/#std.BufSet +[buf-set]: https://ziglang.org/documentation/0.17.0/std/#std.BufSet [zig-hashmaps-explained]: https://devlog.hexops.com/2022/zig-hashmaps-explained/ [zighelp]: https://zighelp.org/chapter-2/#hash-maps diff --git a/exercises/practice/anagram/.meta/example.zig b/exercises/practice/anagram/.meta/example.zig index 336d6889..668036b5 100644 --- a/exercises/practice/anagram/.meta/example.zig +++ b/exercises/practice/anagram/.meta/example.zig @@ -4,7 +4,7 @@ const mem = std.mem; /// Returns the case-insensitive counts of English letters in `s`. /// Caller guarantees that `s` contains at most 15 of a single letter. fn count(s: []const u8) [26]u4 { - var result = [_]u4{0} ** 26; + var result: [26]u4 = @splat(0); for (s) |c| { switch (c) { 'A'...'Z' => result[c - 'A'] += 1, diff --git a/exercises/practice/dnd-character/.docs/instructions.append.md b/exercises/practice/dnd-character/.docs/instructions.append.md index fc54b46c..ed104f46 100644 --- a/exercises/practice/dnd-character/.docs/instructions.append.md +++ b/exercises/practice/dnd-character/.docs/instructions.append.md @@ -17,7 +17,7 @@ A correct implementation has less than a 0.01% chance of failing each test. See the instructions above for a definition of what an ability score is. -[random]: https://ziglang.org/documentation/0.16.0/std/#std.Random -[random-seed]: https://ziglang.org/documentation/0.16.0/std/#std.testing.random_seed +[random]: https://ziglang.org/documentation/0.17.0/std/#std.Random +[random-seed]: https://ziglang.org/documentation/0.17.0/std/#std.testing.random_seed [chi-squared-test]: https://en.wikipedia.org/wiki/Pearson%27s_chi-squared_test [p-value]: https://en.wikipedia.org/wiki/P-value diff --git a/exercises/practice/isogram/.approaches/introduction.md b/exercises/practice/isogram/.approaches/introduction.md index ed55fb8c..8b3a250c 100644 --- a/exercises/practice/isogram/.approaches/introduction.md +++ b/exercises/practice/isogram/.approaches/introduction.md @@ -62,7 +62,7 @@ pub fn isIsogram(str: []const u8) bool { seen |= mask; } // Pad the remaining bytes with zeroes to fill one last block. - var padded = [_]u8{0} ** block_len; + var padded: [block_len]u8 = @splat(0); @memcpy(padded[0 .. str.len - i], str[i..]); const mask = letterMask(padded) orelse return false; return seen & mask == 0; diff --git a/exercises/practice/isogram/.approaches/simd/content.md b/exercises/practice/isogram/.approaches/simd/content.md index f07dea5e..f11a9670 100644 --- a/exercises/practice/isogram/.approaches/simd/content.md +++ b/exercises/practice/isogram/.approaches/simd/content.md @@ -28,7 +28,7 @@ pub fn isIsogram(str: []const u8) bool { seen |= mask; } // Pad the remaining bytes with zeroes to fill one last block. - var padded = [_]u8{0} ** block_len; + var padded: [block_len]u8 = @splat(0); @memcpy(padded[0 .. str.len - i], str[i..]); const mask = letterMask(padded) orelse return false; return seen & mask == 0; diff --git a/exercises/practice/pangram/.meta/example.zig b/exercises/practice/pangram/.meta/example.zig index 4a644a3a..0e2172dc 100644 --- a/exercises/practice/pangram/.meta/example.zig +++ b/exercises/practice/pangram/.meta/example.zig @@ -1,7 +1,7 @@ pub fn isPangram(s: []const u8) bool { if (s.len < 26) return false; - var letters = [_]bool{false} ** 26; + var letters: [26]bool = @splat(false); for (s) |c| { const i = switch (c) { 'A'...'Z' => c - 'A', diff --git a/exercises/practice/perfect-numbers/.docs/instructions.append.md b/exercises/practice/perfect-numbers/.docs/instructions.append.md index e9969679..e7233b62 100644 --- a/exercises/practice/perfect-numbers/.docs/instructions.append.md +++ b/exercises/practice/perfect-numbers/.docs/instructions.append.md @@ -8,6 +8,6 @@ For more details, see the [Zig Language Reference][zig-reference] and the implem However, note that this exercise does not currently test an input of 0 (because `std.testing` does [not yet support expecting a panic][proposal]). -[zig-reference]: https://ziglang.org/documentation/0.16.0/#unreachable -[assert]: https://ziglang.org/documentation/0.16.0/std/#std.debug.assert +[zig-reference]: https://ziglang.org/documentation/0.17.0/#unreachable +[assert]: https://ziglang.org/documentation/0.17.0/std/#std.debug.assert [proposal]: https://github.com/ziglang/zig/issues/1356 diff --git a/exercises/practice/queen-attack/test_queen_attack.zig b/exercises/practice/queen-attack/test_queen_attack.zig index 5511811a..fa04c476 100644 --- a/exercises/practice/queen-attack/test_queen_attack.zig +++ b/exercises/practice/queen-attack/test_queen_attack.zig @@ -5,15 +5,15 @@ const queen_attack = @import("queen_attack.zig"); const QueenError = queen_attack.QueenError; test "queen has exactly two fields" { - try testing.expectEqual(2, std.meta.fields(queen_attack.Queen).len); + try testing.expectEqual(2, @typeInfo(queen_attack.Queen).@"struct".field_names.len); } test "queen with a valid position" { const queen = try queen_attack.Queen.init(2, 2); // Allow the fields to have any name. - const fields = std.meta.fields(@TypeOf(queen)); - inline for (fields) |f| { - const actual = @field(queen, f.name); + const field_names = @typeInfo(@TypeOf(queen)).@"struct".field_names; + inline for (field_names) |name| { + const actual = @field(queen, name); const expected = @as(@TypeOf(actual), 2); try testing.expectEqual(expected, actual); } diff --git a/generators/exercises/queen_attack.py b/generators/exercises/queen_attack.py index 29a8488e..1692a833 100644 --- a/generators/exercises/queen_attack.py +++ b/generators/exercises/queen_attack.py @@ -19,7 +19,7 @@ def gen_case(case): inp = case["input"] if prop == "fields": n = case["expected"] - return f" try testing.expectEqual({n}, std.meta.fields(queen_attack.Queen).len);\n" + return f" try testing.expectEqual({n}, @typeInfo(queen_attack.Queen).@\"struct\".field_names.len);\n" if prop == "create": pos = inp["queen"]["position"] row, col = pos["row"], pos["column"] @@ -32,9 +32,9 @@ def gen_case(case): return ( f" const queen = try queen_attack.Queen.init({row}, {col});\n" f" // Allow the fields to have any name.\n" - f" const fields = std.meta.fields(@TypeOf(queen));\n" - f" inline for (fields) |f| {{\n" - f" const actual = @field(queen, f.name);\n" + f" const field_names = @typeInfo(@TypeOf(queen)).@\"struct\".field_names;\n" + f" inline for (field_names) |name| {{\n" + f" const actual = @field(queen, name);\n" f" const expected = @as(@TypeOf(actual), {row});\n" f" try testing.expectEqual(expected, actual);\n" f" }}\n"