diff options
| author | Mel <mel@rnrd.eu> | 2026-05-24 18:18:23 +0200 |
|---|---|---|
| committer | Mel <mel@rnrd.eu> | 2026-05-24 18:18:23 +0200 |
| commit | a76fd9b5af153773273121c7aec2a9cbeed1dfb7 (patch) | |
| tree | a6c619e44df4f38f60c457b9122e207b0a3c09f0 /boot/catboot.c | |
| parent | 8c4c219c945dfb41415e04654f488f7880e58ca2 (diff) | |
| download | catskill-a76fd9b5af153773273121c7aec2a9cbeed1dfb7.tar.zst catskill-a76fd9b5af153773273121c7aec2a9cbeed1dfb7.zip | |
Make diagnostics generic over passes, condensing different error handling
Signed-off-by: Mel <mel@rnrd.eu>
Diffstat (limited to 'boot/catboot.c')
| -rw-r--r-- | boot/catboot.c | 25 |
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()); |
