Commit 7277670843

shiimizu <shiimizu@protonmail.com>
2019-10-31 18:23:02
Add error when too few arguments are provided to std.fmt
1 parent f81f36e
Changed files (1)
lib
lib/std/fmt.zig
@@ -167,6 +167,10 @@ pub fn format(
                 '}' => {
                     const arg_to_print = comptime nextArg(&used_pos_args, maybe_pos_arg, &next_arg);
 
+                    if (arg_to_print >= args.len) {
+                        @compileError("Too few arguments");
+                    }
+
                     try formatType(
                         args[arg_to_print],
                         fmt[0..0],