From 2c0caa853359f46be0b72d32def8287c50a3507f Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Mon, 9 Nov 2020 20:51:09 -0700 Subject: [PATCH] main: updateModule returns an error when there are any compile errors closes #6976 --- src/main.zig | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/main.zig b/src/main.zig index 7df8cb1eda..0520724f73 100644 --- a/src/main.zig +++ b/src/main.zig @@ -1707,7 +1707,10 @@ fn buildOutputType( } }; - try updateModule(gpa, comp, zir_out_path, hook); + updateModule(gpa, comp, zir_out_path, hook) catch |err| switch (err) { + error.SemanticAnalyzeFail => process.exit(1), + else => |e| return e, + }; if (build_options.is_stage1 and comp.stage1_lock != null and watch) { warn("--watch is not recommended with the stage1 backend; it leaks memory and is not capable of incremental compilation", .{}); @@ -1819,7 +1822,10 @@ fn buildOutputType( if (output_mode == .Exe) { try comp.makeBinFileWritable(); } - try updateModule(gpa, comp, zir_out_path, hook); + updateModule(gpa, comp, zir_out_path, hook) catch |err| switch (err) { + error.SemanticAnalyzeFail => continue, + else => |e| return e, + }; } else if (mem.eql(u8, actual_line, "exit")) { break; } else if (mem.eql(u8, actual_line, "help")) { @@ -1849,6 +1855,7 @@ fn updateModule(gpa: *Allocator, comp: *Compilation, zir_out_path: ?[]const u8, for (errors.list) |full_err_msg| { full_err_msg.renderToStdErr(); } + return error.SemanticAnalyzeFail; } else switch (hook) { .none => {}, .print => |bin_path| try io.getStdOut().writer().print("{s}\n", .{bin_path}),