From 1b6fc912bfad5a2b0e047835f6778137e4aabe5b Mon Sep 17 00:00:00 2001 From: Malte Voos Date: Sun, 30 Jun 2024 21:31:53 +0200 Subject: improve error messages --- src/error/Error.ml | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) (limited to 'src/error') 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 + "@[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 -- cgit 1.4.1