Commit 2d42532fec

Andrew Kelley <andrew@ziglang.org>
2020-11-12 03:35:07
main: clean up the error message for missing positional args
1 parent bf73db7
Changed files (1)
src/main.zig
@@ -1266,20 +1266,6 @@ fn buildOutputType(
         fatal("`zig test` expects a zig source file argument", .{});
     }
 
-    if (link_objects.items.len == 0 and root_src_file == null and
-        c_source_files.items.len == 0 and !show_builtin)
-    {
-        switch (arg_mode) {
-            .run => fatal("`zig run` expects at least one positional argument", .{}),
-            .build => |build_type| switch (build_type) {
-                .Exe => fatal("`zig build-exe` expects at least one positional argument", .{}),
-                .Lib => fatal("`zig build-lib` expects at least one positional argument", .{}),
-                .Obj => fatal("`zig build-obj` expects at least one positional argument", .{}),
-            },
-            else => {},
-        }
-    }
-
     const root_name = if (provided_name) |n| n else blk: {
         if (arg_mode == .zig_test) {
             break :blk "test";
@@ -1298,9 +1284,12 @@ fn buildOutputType(
         } else if (show_builtin) {
             break :blk "builtin";
         } else if (arg_mode == .run) {
-            break :blk "run";
+            fatal("`zig run` expects at least one positional argument", .{});
+            // TODO once the attempt to unwrap error: LinkingWithoutZigSourceUnimplemented
+            // is solved, remove the above fatal() and uncomment the `break` below.
+            //break :blk "run";
         } else {
-            fatal("--name [name] not provided and unable to infer", .{});
+            fatal("expected a positional argument, -femit-bin=[path], --show-builtin, or --name [name]", .{});
         }
     };