Commit 25051832b3

Andrew Kelley <andrew@ziglang.org>
2019-12-31 19:13:13
std.fmt.format: add helpful compile error for non-tuple args
1 parent d972d1c
Changed files (1)
lib
lib/std/fmt.zig
@@ -94,6 +94,9 @@ pub fn format(
     args: var,
 ) Errors!void {
     const ArgSetType = @IntType(false, 32);
+    if (@typeInfo(@TypeOf(args)) != .Struct) {
+        @compileError("Expected tuple or struct argument, found " ++ @typeName(@TypeOf(args)));
+    }
     if (args.len > ArgSetType.bit_count) {
         @compileError("32 arguments max are supported per format call");
     }