Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions compiler/frontend/bs_ast_invariant.ml
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,9 @@ let emit_external_warnings : iterator =
( Nonrecursive,
[{ptype_kind = Ptype_variant ({pcd_res = Some _} :: _)}] ) ->
Location.raise_errorf ~loc:str_item.pstr_loc
"GADT has to be recursive types, please try `type rec'"
"GADTs require recursive type syntax.\n\
Please define your type using `type rec` instead of `type`.\n\
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should avoid saying "please" here, we don't do that in other error messages either.

Example: type rec t = ..."
| _ -> super.structure_item self str_item);
expr =
(fun self ({pexp_loc = loc} as a) ->
Expand All @@ -95,7 +97,8 @@ let emit_external_warnings : iterator =
try ignore (Ext_string.hash_number_as_i32_exn s : int32)
with _ ->
Location.raise_errorf ~loc
"This number is too large to cause int overlow")
"Integer literal exceeds int32 range. Use float or BigInt if \
larger values are required.")
| _ -> super.expr self a);
label_declaration =
(fun self lbl ->
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@

We've found a bug for you!
/.../fixtures/gadt_rec_missing.res:4:1-8:27

2 │ type daylight
3 │
4 │ type timezone<_> =
5 │  | EST: timezone<standard>
6 │  | EDT: timezone<daylight>
7 │  | CST: timezone<standard>
8 │  | CDT: timezone<daylight>
9 │

GADTs require recursive type syntax.
Please define your type using `type rec` instead of `type`.
Example: type rec t = ...
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@

We've found a bug for you!
/.../fixtures/polyvariant_int_too_large.res:1:9-29

1 │ let x = #12345678901234567890
2 │

Integer literal exceeds int32 range. Use float or BigInt if larger values are required.
8 changes: 8 additions & 0 deletions tests/build_tests/super_errors/fixtures/gadt_rec_missing.res
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
type standard
type daylight

type timezone<_> =
| EST: timezone<standard>
| EDT: timezone<daylight>
| CST: timezone<standard>
| CDT: timezone<daylight>
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
let x = #12345678901234567890
Loading