authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2020-11-09 20:51:09-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2020-11-09 20:52:08-07:00
log2c0caa853359f46be0b72d32def8287c50a3507f
tree354577efcc42500ac4f239c8f6e9e28b0d9c831e
parent904c513a1e6fee98f4c431fe8213f7f32e18be6a

main: updateModule returns an error when there are any compile errors

closes #6976

1 files changed, 9 insertions(+), 2 deletions(-)

src/main.zig+9-2
......@@ -1707,7 +1707,10 @@ fn buildOutputType(
17071707 }
17081708 };
17091709
1710 try updateModule(gpa, comp, zir_out_path, hook);
1710 updateModule(gpa, comp, zir_out_path, hook) catch |err| switch (err) {
1711 error.SemanticAnalyzeFail => process.exit(1),
1712 else => |e| return e,
1713 };
17111714
17121715 if (build_options.is_stage1 and comp.stage1_lock != null and watch) {
17131716 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(
18191822 if (output_mode == .Exe) {
18201823 try comp.makeBinFileWritable();
18211824 }
1822 try updateModule(gpa, comp, zir_out_path, hook);
1825 updateModule(gpa, comp, zir_out_path, hook) catch |err| switch (err) {
1826 error.SemanticAnalyzeFail => continue,
1827 else => |e| return e,
1828 };
18231829 } else if (mem.eql(u8, actual_line, "exit")) {
18241830 break;
18251831 } else if (mem.eql(u8, actual_line, "help")) {
......@@ -1849,6 +1855,7 @@ fn updateModule(gpa: *Allocator, comp: *Compilation, zir_out_path: ?[]const u8,
18491855 for (errors.list) |full_err_msg| {
18501856 full_err_msg.renderToStdErr();
18511857 }
1858 return error.SemanticAnalyzeFail;
18521859 } else switch (hook) {
18531860 .none => {},
18541861 .print => |bin_path| try io.getStdOut().writer().print("{s}\n", .{bin_path}),