From 25051832b37bab8d945e6284899a4c916ae00ada Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Tue, 31 Dec 2019 13:13:13 -0500 Subject: [PATCH] std.fmt.format: add helpful compile error for non-tuple args --- lib/std/fmt.zig | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/std/fmt.zig b/lib/std/fmt.zig index f1249afa97..1d64468eb8 100644 --- a/lib/std/fmt.zig +++ b/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"); }