about summary refs log tree commit diff
path: root/src/error
diff options
context:
space:
mode:
authorMalte Voos <git@mal.tc>2024-06-30 21:31:53 +0200
committerMalte Voos <git@mal.tc>2024-06-30 21:31:53 +0200
commit1b6fc912bfad5a2b0e047835f6778137e4aabe5b (patch)
treed8e2e26461a6e09e21e0f135d80308acf40dcf10 /src/error
parentfab70aaf2947ff1369757355fbf11437c6db35ff (diff)
downloadtoytt-1b6fc912bfad5a2b0e047835f6778137e4aabe5b.tar.gz
toytt-1b6fc912bfad5a2b0e047835f6778137e4aabe5b.zip
improve error messages
Diffstat (limited to 'src/error')
-rw-r--r--src/error/Error.ml27
1 files changed, 17 insertions, 10 deletions
diff --git a/src/error/Error.ml b/src/error/Error.ml
index ee04c23..555d41c 100644
--- a/src/error/Error.ml
+++ b/src/error/Error.ml
@@ -4,8 +4,8 @@ struct
     | IllegalCharacter
     | SyntaxError
     | UnboundVariable
-    | IllTyped
-    | CannotInferType
+    | TypeMismatch
+    | NotInferable
     | Bug
 
   let default_severity : t -> Asai.Diagnostic.severity =
@@ -13,8 +13,8 @@ struct
     | IllegalCharacter -> Error
     | SyntaxError -> Error
     | UnboundVariable -> Error
-    | IllTyped -> Error
-    | CannotInferType -> Error
+    | TypeMismatch -> Error
+    | NotInferable -> Error
     | Bug -> Bug
 
   let short_code : t -> string =
@@ -24,17 +24,24 @@ struct
     | SyntaxError -> "E102"
     (* elaboration errors *)
     | UnboundVariable -> "E201"
-    | IllTyped -> "E202"
-    | CannotInferType -> "E202"
+    | TypeMismatch -> "E202"
+    | NotInferable -> "E203"
     (* misc *)
     | Bug -> "E900"
 end
 
 include Asai.Reporter.Make(Message)
 
-let illegal_character ~loc char = fatalf ~loc IllegalCharacter "illegal character '%s'" (Char.escaped char)
-let syntax_error ~loc = fatalf ~loc SyntaxError "syntax error"
-let unbound_variable id = fatalf UnboundVariable "unbound variable '%a'" Ident.pp id
-let expected_universe fmt x = fatalf IllTyped "expected a universe but got %a" fmt x
+let illegal_character ~loc char = fatalf ~loc IllegalCharacter
+    "illegal character '%s'" (Char.escaped char)
+let syntax_error ~loc = fatalf ~loc SyntaxError
+    "syntax error"
+let unbound_variable id = fatalf UnboundVariable
+    "unbound variable '%a'" Ident.pp id
+let type_mismatch ?loc fmt_expected expected fmt_found found = fatalf ?loc TypeMismatch
+    "@[<v>type mismatch:@,expected: @[%a@]@,   found: @[%a@]@]"
+    fmt_expected expected fmt_found found
+let not_inferable () = fatalf NotInferable
+    "cannot infer type"
 
 let bug msg = fatalf Bug msg