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(...@@ -1707,7 +1707,10 @@ fn buildOutputType(
1707 }1707 }
1708 };1708 };
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
1712 if (build_options.is_stage1 and comp.stage1_lock != null and watch) {1715 if (build_options.is_stage1 and comp.stage1_lock != null and watch) {
1713 warn("--watch is not recommended with the stage1 backend; it leaks memory and is not capable of incremental compilation", .{});1716 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(...@@ -1819,7 +1822,10 @@ fn buildOutputType(
1819 if (output_mode == .Exe) {1822 if (output_mode == .Exe) {
1820 try comp.makeBinFileWritable();1823 try comp.makeBinFileWritable();
1821 }1824 }
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 };
1823 } else if (mem.eql(u8, actual_line, "exit")) {1829 } else if (mem.eql(u8, actual_line, "exit")) {
1824 break;1830 break;
1825 } else if (mem.eql(u8, actual_line, "help")) {1831 } else if (mem.eql(u8, actual_line, "help")) {
...@@ -1849,6 +1855,7 @@ fn updateModule(gpa: *Allocator, comp: *Compilation, zir_out_path: ?[]const u8,...@@ -1849,6 +1855,7 @@ fn updateModule(gpa: *Allocator, comp: *Compilation, zir_out_path: ?[]const u8,
1849 for (errors.list) |full_err_msg| {1855 for (errors.list) |full_err_msg| {
1850 full_err_msg.renderToStdErr();1856 full_err_msg.renderToStdErr();
1851 }1857 }
1858 return error.SemanticAnalyzeFail;
1852 } else switch (hook) {1859 } else switch (hook) {
1853 .none => {},1860 .none => {},
1854 .print => |bin_path| try io.getStdOut().writer().print("{s}\n", .{bin_path}),1861 .print => |bin_path| try io.getStdOut().writer().print("{s}\n", .{bin_path}),