diff options
| -rw-r--r-- | lib/checks/get_type.ml | 3 | ||||
| -rw-r--r-- | lib/checks/type_of.ml | 5 | ||||
| -rw-r--r-- | test/type_of.ml | 19 |
3 files changed, 18 insertions, 9 deletions
diff --git a/lib/checks/get_type.ml b/lib/checks/get_type.ml index 00270c2..c6d1e44 100644 --- a/lib/checks/get_type.ml +++ b/lib/checks/get_type.ml @@ -12,8 +12,7 @@ type type_of = | Integer (** A numeric value *) | Bool (** A boolean, not a real type *) | String (** String value *) - | NumericString - [@printer fun fmt _ -> Format.pp_print_string fmt "Integer as String"] + | NumericString [@printer fun fmt _ -> Format.pp_print_string fmt "String"] (** String containing a numeric value *) [@@deriving show { with_path = false }, eq] diff --git a/lib/checks/type_of.ml b/lib/checks/type_of.ml index 243c8b3..4593842 100644 --- a/lib/checks/type_of.ml +++ b/lib/checks/type_of.ml @@ -95,8 +95,9 @@ module Helper = struct else let result_type = match actual.t with Variable v -> v | Raw r -> r in let message = - Format.asprintf "The type %a is expected but got %a" Get_type.pp_type_of - expected Get_type.pp_type_of result_type + Format.asprintf + "The expression has type %a but the context was expecting a %a" + Get_type.pp_type_of result_type Get_type.pp_type_of expected in Report.message level actual.pos message :: report diff --git a/test/type_of.ml b/test/type_of.ml index 1b84faa..88b55b7 100644 --- a/test/type_of.ml +++ b/test/type_of.ml @@ -8,7 +8,9 @@ let message level = { level; loc = _position; - message = "The type Integer is expected but got String"; + message = + "The expression has type String but the context was expecting a \ + Integer"; }; ] @@ -18,7 +20,9 @@ let message' level = { level; loc = _position; - message = "The type String is expected but got Integer"; + message = + "The expression has type Integer but the context was expecting a \ + String"; }; ] @@ -28,7 +32,9 @@ let integer_as_string = { level = Warn; loc = _position; - message = "The type Integer is expected but got Integer as String"; + message = + "The expression has type String but the context was expecting a \ + Integer"; }; ] @@ -60,7 +66,9 @@ let type_comparaison_mismatch () = { level = Warn; loc = _position; - message = "The type String is expected but got Integer"; + message = + "The expression has type Integer but the context was expecting a \ + String"; }; ] @@ -70,7 +78,8 @@ let wrong_predicate () = { level = Warn; loc = _position; - message = "The type Bool is expected but got String"; + message = + "The expression has type String but the context was expecting a Bool"; }; ] |
