Commit ecb77af534
Changed files (2)
test
stage1
behavior
bugs
test/stage1/behavior/bugs/3742.zig
@@ -0,0 +1,38 @@
+const std = @import("std");
+
+pub const GET = struct {
+ key: []const u8,
+
+ pub fn init(key: []const u8) GET {
+ return .{ .key = key };
+ }
+
+ pub const Redis = struct {
+ pub const Command = struct {
+ pub fn serialize(self: GET, comptime rootSerializer: type) void {
+ return rootSerializer.serializeCommand(.{ "GET", self.key });
+ }
+ };
+ };
+};
+
+pub fn isCommand(comptime T: type) bool {
+ const tid = @typeId(T);
+ return (tid == .Struct or tid == .Enum or tid == .Union) and
+ @hasDecl(T, "Redis") and @hasDecl(T.Redis, "Command");
+}
+
+pub const ArgSerializer = struct {
+ pub fn serializeCommand(command: var) void {
+ const CmdT = @typeOf(command);
+
+ if (comptime isCommand(CmdT)) {
+ // COMMENTING THE NEXT LINE REMOVES THE ERROR
+ return CmdT.Redis.Command.serialize(command, ArgSerializer);
+ }
+ }
+};
+
+test "fixed" {
+ ArgSerializer.serializeCommand(GET.init("banana"));
+}
test/stage1/behavior.zig
@@ -38,6 +38,7 @@ comptime {
_ = @import("behavior/bugs/3112.zig");
_ = @import("behavior/bugs/3367.zig");
_ = @import("behavior/bugs/3384.zig");
+ _ = @import("behavior/bugs/3742.zig");
_ = @import("behavior/bugs/394.zig");
_ = @import("behavior/bugs/421.zig");
_ = @import("behavior/bugs/529.zig");