about summary refs log tree commit diff
path: root/boot/catboot.c
diff options
context:
space:
mode:
Diffstat (limited to 'boot/catboot.c')
-rw-r--r--boot/catboot.c25
1 files changed, 13 insertions, 12 deletions
diff --git a/boot/catboot.c b/boot/catboot.c
index 3919a2a..e340d48 100644
--- a/boot/catboot.c
+++ b/boot/catboot.c
@@ -130,12 +130,11 @@ debug_lower_pass(struct Source_File source_file)
     }
 
     struct Unit unit = { 0 };
-    lower_tree(&tree, source_file, &unit);
+    lower_tree(&tree, &unit);
     printer(&unit);
 
-    // diagnostics are part of the printed unit, so the caller can read
-    // them from the dump. always returning success keeps snapshot tests
-    // viable for both the green and the diagnostic paths.
+    // always succeed. errors live in the printed unit and snapshot tests
+    // pick them up from there.
     return 0;
 }
 
@@ -156,11 +155,12 @@ debug_transpile_pass(struct Source_File source_file)
     }
 
     struct Unit unit = { 0 };
-    lower_tree(&tree, source_file, &unit);
-    if (unit.had_error) {
-        log_error("lowering finished with errors\n");
-        return 1;
+    lower_tree(&tree, &unit);
+    FOR_EACH_ARRAY (struct Lower_Error, err, &unit.lower_errors) {
+        struct Diagnostic d = lower_error_to_diagnostic(err, &unit, source_file);
+        diagnostic_display(source_file, &d, stderr);
     }
+    if (unit.had_error) return 1;
 
     struct Transpile_Output output = transpile_output_from_file(stdout);
 
@@ -294,11 +294,12 @@ default_command(struct Command_Arguments* arguments)
     }
 
     struct Unit unit = { 0 };
-    lower_tree(&tree, source_file, &unit);
-    if (unit.had_error) {
-        log_error("lowering finished with errors\n");
-        return COMMAND_FAIL;
+    lower_tree(&tree, &unit);
+    FOR_EACH_ARRAY (struct Lower_Error, err, &unit.lower_errors) {
+        struct Diagnostic d = lower_error_to_diagnostic(err, &unit, source_file);
+        diagnostic_display(source_file, &d, stderr);
     }
+    if (unit.had_error) return COMMAND_FAIL;
 
     struct Transpiler transpiler;
     transpiler_new(&transpiler, transpile_output_from_string());