Skip to content

Commit 1701f12

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

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

compiler/frontend/bs_ast_invariant.ml

Lines changed: 5 additions & 2 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 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) ->
@@ -95,7 +97,8 @@ let emit_external_warnings : iterator =
9597
try ignore (Ext_string.hash_number_as_i32_exn s : int32)
9698
with _ ->
9799
Location.raise_errorf ~loc
98-
"This number is too large to cause int overlow")
100+
"Integer literal exceeds int32 range. Use float or BigInt if \
101+
larger values are required.")
99102
| _ -> super.expr self a);
100103
label_declaration =
101104
(fun self lbl ->

0 commit comments

Comments
 (0)