about summary refs log tree commit diff
path: root/boot/ir.c
diff options
context:
space:
mode:
authorMel <mel@rnrd.eu>2026-05-24 18:18:23 +0200
committerMel <mel@rnrd.eu>2026-05-24 18:18:23 +0200
commita76fd9b5af153773273121c7aec2a9cbeed1dfb7 (patch)
treea6c619e44df4f38f60c457b9122e207b0a3c09f0 /boot/ir.c
parent8c4c219c945dfb41415e04654f488f7880e58ca2 (diff)
downloadcatskill-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/ir.c')
-rw-r--r--boot/ir.c44
1 files changed, 27 insertions, 17 deletions
diff --git a/boot/ir.c b/boot/ir.c
index 4bdfc6e..6ea055e 100644
--- a/boot/ir.c
+++ b/boot/ir.c
@@ -444,19 +444,33 @@ struct Import
     struct Span span;
 };
 
-enum Diagnostic_Severity
-{
-    DIAGNOSTIC_NOTE,
-    DIAGNOSTIC_WARNING,
-    DIAGNOSTIC_ERROR,
-};
-
-// TODO: we might want to take this out to be used for other passes.
-struct Diagnostic
-{
-    enum Diagnostic_Severity severity;
+enum Lower_Error_Kind
+{
+    LOWER_ERROR_NONE,
+    LOWER_ERROR_UNDEFINED_TYPE,
+    LOWER_ERROR_DUPLICATE_TYPE,
+    LOWER_ERROR_DUPLICATE_FUNCTION,
+    LOWER_ERROR_NAME_SHADOWS,
+    LOWER_ERROR_TYPE_CYCLE,
+    LOWER_ERROR_ASSIGNMENT_AS_EXPRESSION,
+    LOWER_ERROR_RANGE_OUTSIDE_LOOP,
+    LOWER_ERROR_CONSTRUCT_SUBJECT_NOT_NAME,
+    LOWER_ERROR_TYPE_EXPRESSION_IN_BODY,
+    LOWER_ERROR_UNSUPPORTED_TOP_LEVEL,
+    LOWER_ERROR_UNKNOWN_LOOP_STYLE,
+    LOWER_ERROR_UNKNOWN_COMPOUND_ASSIGN,
+    LOWER_ERROR_UNIMPLEMENTED,
+};
+
+struct Lower_Error
+{
+    enum Lower_Error_Kind kind;
     struct Span span;
-    struct String message;
+    
+    // per-error details, meaning depends on each error kind!
+    struct String name;
+    struct String detail;
+    Array(Type_Id) cycle_chain;
 };
 
 // a single translation unit.
@@ -472,7 +486,7 @@ struct Unit
     Array(Type_Id) type_emission_order;
 
     bool had_error;
-    Array(struct Diagnostic) diagnostics;
+    Array(struct Lower_Error) lower_errors;
 };
 
 REGION(struct Type, type)
@@ -655,10 +669,6 @@ ir_make_construct(Type_Id type_id, Array(struct Construct_Field) fields, struct
     return expression_new(EXPRESSION_CONSTRUCT, v, span);
 }
 
-// type-ref constructors.
-// `bare` is the no-modifier form; `pointer` wraps one `&` modifier; `with_mods`
-// takes a fully-formed mods array (caller owns it).
-
 struct Type_Ref
 type_ref_bare(Type_Id type_id)
 {