From b2f56c7cea6475d5335dd8e8642181817fdc390b Mon Sep 17 00:00:00 2001 From: Chris Boesch Date: Mon, 2 Sep 2024 19:33:59 +0200 Subject: [PATCH] Fixes several changes in std.builtin.zig --- README.md | 1 + build.zig | 2 +- exercises/065_builtins2.zig | 8 ++++---- exercises/071_comptime6.zig | 2 +- exercises/076_sentinels.zig | 4 ++-- patches/patches/065_builtins2.patch | 10 +++++----- patches/patches/071_comptime6.patch | 6 +++--- patches/patches/076_sentinels.patch | 4 ++-- patches/patches/082_anonymous_structs3.patch | 6 +++--- 9 files changed, 22 insertions(+), 21 deletions(-) diff --git a/README.md b/README.md index 417cf88..7b8c8c1 100644 --- a/README.md +++ b/README.md @@ -89,6 +89,7 @@ that if you update one, you may need to also update the other. ### Version Changes Version-0.14.0-dev.1224 +* *2024-07-02* zig 0.14.0-dev.1409 - several changes in std.builtin, see [#21225](https://github.com/ziglang/zig/pull/21225) * *2024-08-04* zig 0.14.0-dev.1224 - several changes in build system, see [#21115](https://github.com/ziglang/zig/pull/21115) * *2024-08-04* zig 0.14.0-dev.839 - several changes in build system, see [#20580](https://github.com/ziglang/zig/pull/20580), [#20600](https://github.com/ziglang/zig/issues/20600) * *2024-06-17* zig 0.14.0-dev.42 - changes in `std.mem.split and tokenize` - see [#15579](https://github.com/ziglang/zig/pull/15579) diff --git a/build.zig b/build.zig index c488608..0ddc23f 100644 --- a/build.zig +++ b/build.zig @@ -15,7 +15,7 @@ const print = std.debug.print; // 1) Getting Started // 2) Version Changes comptime { - const required_zig = "0.14.0-dev.1224"; + const required_zig = "0.14.0-dev.1409"; const current_zig = builtin.zig_version; const min_zig = std.SemanticVersion.parse(required_zig) catch unreachable; if (current_zig.order(min_zig) == .lt) { diff --git a/exercises/065_builtins2.zig b/exercises/065_builtins2.zig index 283aca5..0790db4 100644 --- a/exercises/065_builtins2.zig +++ b/exercises/065_builtins2.zig @@ -94,7 +94,7 @@ pub fn main() void { print("He has room in his heart for:", .{}); // A StructFields array - const fields = @typeInfo(Narcissus).Struct.fields; + const fields = @typeInfo(Narcissus).@"struct".fields; // 'fields' is a slice of StructFields. Here's the declaration: // @@ -110,15 +110,15 @@ pub fn main() void { // name will not be printed if the field is of type 'void' // (which is a zero-bit type that takes up no space at all!): if (fields[0].??? != void) { - print(" {s}", .{@typeInfo(Narcissus).Struct.fields[0].name}); + print(" {s}", .{@typeInfo(Narcissus).@"struct".fields[0].name}); } if (fields[1].??? != void) { - print(" {s}", .{@typeInfo(Narcissus).Struct.fields[1].name}); + print(" {s}", .{@typeInfo(Narcissus).@"struct".fields[1].name}); } if (fields[2].??? != void) { - print(" {s}", .{@typeInfo(Narcissus).Struct.fields[2].name}); + print(" {s}", .{@typeInfo(Narcissus).@"struct".fields[2].name}); } // Yuck, look at all that repeated code above! I don't know diff --git a/exercises/071_comptime6.zig b/exercises/071_comptime6.zig index 7723291..5938abc 100644 --- a/exercises/071_comptime6.zig +++ b/exercises/071_comptime6.zig @@ -38,7 +38,7 @@ pub fn main() void { // Please use an 'inline for' to implement the block below // for each field in the slice 'fields'! - const fields = @typeInfo(Narcissus).Struct.fields; + const fields = @typeInfo(Narcissus).@"struct".fields; ??? { if (field.type != void) { diff --git a/exercises/076_sentinels.zig b/exercises/076_sentinels.zig index 357bd95..accb600 100644 --- a/exercises/076_sentinels.zig +++ b/exercises/076_sentinels.zig @@ -78,7 +78,7 @@ fn printSequence(my_seq: anytype) void { // a switch to handle printing the Array or Pointer fields, // depending on which type of my_seq was passed in: switch (my_typeinfo) { - .Array => { + .array => { print("Array:", .{}); // Loop through the items in my_seq. @@ -86,7 +86,7 @@ fn printSequence(my_seq: anytype) void { print("{}", .{s}); } }, - .Pointer => { + .pointer => { // Check this out - it's pretty cool: const my_sentinel = sentinel(@TypeOf(my_seq)); print("Many-item pointer:", .{}); diff --git a/patches/patches/065_builtins2.patch b/patches/patches/065_builtins2.patch index 4b0ccd2..d5da950 100644 --- a/patches/patches/065_builtins2.patch +++ b/patches/patches/065_builtins2.patch @@ -1,5 +1,5 @@ ---- exercises/065_builtins2.zig 2023-10-03 22:15:22.125574535 +0200 -+++ answers/065_builtins2.zig 2023-10-05 20:04:07.136101712 +0200 +--- exercises/065_builtins2.zig 2024-09-02 19:15:56.569952315 +0200 ++++ answers/065_builtins2.zig 2024-09-02 19:13:44.280600350 +0200 @@ -58,7 +58,7 @@ // Oops! We cannot leave the 'me' and 'myself' fields // undefined. Please set them here: @@ -24,16 +24,16 @@ // (which is a zero-bit type that takes up no space at all!): - if (fields[0].??? != void) { + if (fields[0].type != void) { - print(" {s}", .{@typeInfo(Narcissus).Struct.fields[0].name}); + print(" {s}", .{@typeInfo(Narcissus).@"struct".fields[0].name}); } - if (fields[1].??? != void) { + if (fields[1].type != void) { - print(" {s}", .{@typeInfo(Narcissus).Struct.fields[1].name}); + print(" {s}", .{@typeInfo(Narcissus).@"struct".fields[1].name}); } - if (fields[2].??? != void) { + if (fields[2].type != void) { - print(" {s}", .{@typeInfo(Narcissus).Struct.fields[2].name}); + print(" {s}", .{@typeInfo(Narcissus).@"struct".fields[2].name}); } diff --git a/patches/patches/071_comptime6.patch b/patches/patches/071_comptime6.patch index 8731344..98fb6e3 100644 --- a/patches/patches/071_comptime6.patch +++ b/patches/patches/071_comptime6.patch @@ -1,8 +1,8 @@ ---- exercises/071_comptime6.zig 2023-10-03 22:15:22.125574535 +0200 -+++ answers/071_comptime6.zig 2023-10-05 20:04:07.162768879 +0200 +--- exercises/071_comptime6.zig 2024-09-02 19:21:50.250454978 +0200 ++++ answers/071_comptime6.zig 2024-09-02 19:21:23.553250563 +0200 @@ -40,7 +40,7 @@ - const fields = @typeInfo(Narcissus).Struct.fields; + const fields = @typeInfo(Narcissus).@"struct".fields; - ??? { + inline for (fields) |field| { diff --git a/patches/patches/076_sentinels.patch b/patches/patches/076_sentinels.patch index cbfae31..7abd01e 100644 --- a/patches/patches/076_sentinels.patch +++ b/patches/patches/076_sentinels.patch @@ -1,5 +1,5 @@ ---- exercises/076_sentinels.zig 2023-10-03 22:15:22.125574535 +0200 -+++ answers/076_sentinels.zig 2023-10-05 20:04:07.186102649 +0200 +--- exercises/076_sentinels.zig 2024-09-02 19:27:04.336781039 +0200 ++++ answers/076_sentinels.zig 2024-09-02 19:26:15.709134934 +0200 @@ -82,7 +82,7 @@ print("Array:", .{}); diff --git a/patches/patches/082_anonymous_structs3.patch b/patches/patches/082_anonymous_structs3.patch index 7beb511..193a65a 100644 --- a/patches/patches/082_anonymous_structs3.patch +++ b/patches/patches/082_anonymous_structs3.patch @@ -1,11 +1,11 @@ ---- exercises/082_anonymous_structs3.zig 2023-10-03 22:15:22.125574535 +0200 -+++ answers/082_anonymous_structs3.zig 2023-10-05 20:04:07.212769813 +0200 +--- exercises/082_anonymous_structs3.zig 2024-08-04 15:57:16.753494020 +0200 ++++ answers/082_anonymous_structs3.zig 2024-09-02 19:30:00.967005314 +0200 @@ -82,14 +82,14 @@ // @typeInfo(Circle).Struct.fields // // This will be an array of StructFields. - const fields = ???; -+ const fields = @typeInfo(@TypeOf(tuple)).Struct.fields; ++ const fields = @typeInfo(@TypeOf(tuple)).@"struct".fields; // 2. Loop through each field. This must be done at compile // time.