Skip to content

Commit 2505183

Browse files
committed
std.fmt.format: add helpful compile error for non-tuple args
1 parent d972d1c commit 2505183

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

lib/std/fmt.zig

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,9 @@ pub fn format(
9494
args: var,
9595
) Errors!void {
9696
const ArgSetType = @IntType(false, 32);
97+
if (@typeInfo(@TypeOf(args)) != .Struct) {
98+
@compileError("Expected tuple or struct argument, found " ++ @typeName(@TypeOf(args)));
99+
}
97100
if (args.len > ArgSetType.bit_count) {
98101
@compileError("32 arguments max are supported per format call");
99102
}

0 commit comments

Comments
 (0)