about summary refs log tree commit diff
path: root/lib/Reporter.ml
blob: a90966c90e6d8b6fc716efc44879480267f0ecb6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
module Message =
struct
  type t =
    | SyntaxError
    | IllTyped
    | UnboundVariable
    | CannotInferType
    | Bug

  let default_severity : t -> Asai.Diagnostic.severity =
    function
    | SyntaxError -> Error
    | IllTyped -> Error
    | UnboundVariable -> Error
    | CannotInferType -> Error
    | Bug -> Bug

  let short_code : t -> string =
    function
    | SyntaxError -> "E001"
    | IllTyped -> "E002"
    | UnboundVariable -> "E003"
    | CannotInferType -> "E004"
    | Bug -> "BUG"
end

include Asai.Reporter.Make(Message)

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 bug msg = fatalf Bug msg