Skip to content

Commit b52a874

Browse files
Better error messages for GADTs and int overflows
1 parent a09a3d7 commit b52a874

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

compiler/frontend/bs_ast_invariant.ml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,9 @@ let emit_external_warnings : iterator =
8585
( Nonrecursive,
8686
[{ptype_kind = Ptype_variant ({pcd_res = Some _} :: _)}] ) ->
8787
Location.raise_errorf ~loc:str_item.pstr_loc
88-
"GADT has to be recursive types, please try `type rec'"
88+
"GADTs in ReScript require recursive type syntax.\n\
89+
Please define your type using `type rec` instead of `type`.\n\
90+
Example: type rec t = ..."
8991
| _ -> super.structure_item self str_item);
9092
expr =
9193
(fun self ({pexp_loc = loc} as a) ->
@@ -94,8 +96,7 @@ let emit_external_warnings : iterator =
9496
| Pexp_variant (s, None) when Ext_string.is_valid_hash_number s -> (
9597
try ignore (Ext_string.hash_number_as_i32_exn s : int32)
9698
with _ ->
97-
Location.raise_errorf ~loc
98-
"This number is too large to cause int overlow")
99+
Location.raise_errorf ~loc "Integer literal does not fit in int32.")
99100
| _ -> super.expr self a);
100101
label_declaration =
101102
(fun self lbl ->

0 commit comments

Comments
 (0)