| author | |
| committer | |
| log | ecb77af5343c58bbd8023ded0ebf241abe1b0dfa |
| tree | 6a60bc2870c64f08726841b78f2d63434eaba7e6 |
| parent | 80a72c225cf2a08e683936921dfda07f93cef1b8 |
| signature |
closes #37422 files changed, 39 insertions(+), 0 deletions(-)
test/stage1/behavior.zig+1| ... | @@ -38,6 +38,7 @@ comptime { | ... | @@ -38,6 +38,7 @@ comptime { |
| 38 | _ = @import("behavior/bugs/3112.zig"); | 38 | _ = @import("behavior/bugs/3112.zig"); |
| 39 | _ = @import("behavior/bugs/3367.zig"); | 39 | _ = @import("behavior/bugs/3367.zig"); |
| 40 | _ = @import("behavior/bugs/3384.zig"); | 40 | _ = @import("behavior/bugs/3384.zig"); |
| 41 | _ = @import("behavior/bugs/3742.zig"); | ||
| 41 | _ = @import("behavior/bugs/394.zig"); | 42 | _ = @import("behavior/bugs/394.zig"); |
| 42 | _ = @import("behavior/bugs/421.zig"); | 43 | _ = @import("behavior/bugs/421.zig"); |
| 43 | _ = @import("behavior/bugs/529.zig"); | 44 | _ = @import("behavior/bugs/529.zig"); |
test/stage1/behavior/bugs/3742.zig created+38| ... | @@ -0,0 +1,38 @@ | ||
| 1 | const std = @import("std"); | ||
| 2 | |||
| 3 | pub const GET = struct { | ||
| 4 | key: []const u8, | ||
| 5 | |||
| 6 | pub fn init(key: []const u8) GET { | ||
| 7 | return .{ .key = key }; | ||
| 8 | } | ||
| 9 | |||
| 10 | pub const Redis = struct { | ||
| 11 | pub const Command = struct { | ||
| 12 | pub fn serialize(self: GET, comptime rootSerializer: type) void { | ||
| 13 | return rootSerializer.serializeCommand(.{ "GET", self.key }); | ||
| 14 | } | ||
| 15 | }; | ||
| 16 | }; | ||
| 17 | }; | ||
| 18 | |||
| 19 | pub fn isCommand(comptime T: type) bool { | ||
| 20 | const tid = @typeId(T); | ||
| 21 | return (tid == .Struct or tid == .Enum or tid == .Union) and | ||
| 22 | @hasDecl(T, "Redis") and @hasDecl(T.Redis, "Command"); | ||
| 23 | } | ||
| 24 | |||
| 25 | pub const ArgSerializer = struct { | ||
| 26 | pub fn serializeCommand(command: var) void { | ||
| 27 | const CmdT = @typeOf(command); | ||
| 28 | |||
| 29 | if (comptime isCommand(CmdT)) { | ||
| 30 | // COMMENTING THE NEXT LINE REMOVES THE ERROR | ||
| 31 | return CmdT.Redis.Command.serialize(command, ArgSerializer); | ||
| 32 | } | ||
| 33 | } | ||
| 34 | }; | ||
| 35 | |||
| 36 | test "fixed" { | ||
| 37 | ArgSerializer.serializeCommand(GET.init("banana")); | ||
| 38 | } | ||