@@ -84,6 +84,8 @@ type error =
84
84
| Field_not_optional of string * type_expr
85
85
| Type_params_not_supported of Longident .t
86
86
| Field_access_on_dict_type
87
+ | Jsx_not_enabled
88
+
87
89
exception Error of Location. t * Env. t * error
88
90
exception Error_forward of Location. error
89
91
@@ -184,7 +186,7 @@ let iter_expression f e =
184
186
| Pexp_pack me -> module_expr me
185
187
| Pexp_await _ -> assert false (* should be handled earlier *)
186
188
| Pexp_jsx_element _ ->
187
- failwith " Pexp_jsx_element should be transformed at this point. "
189
+ raise ( Error (e.pexp_loc, Env. empty, Jsx_not_enabled ))
188
190
and case {pc_lhs = _ ; pc_guard; pc_rhs} =
189
191
may expr pc_guard;
190
192
expr pc_rhs
@@ -3193,7 +3195,7 @@ and type_expect_ ~context ?in_function ?(recarg = Rejected) env sexp ty_expected
3193
3195
raise (Error_forward (Builtin_attributes. error_of_extension ext))
3194
3196
| Pexp_await _ -> (* should be handled earlier *) assert false
3195
3197
| Pexp_jsx_element _ ->
3196
- failwith " Pexp_jsx_element is expected to be transformed at this point "
3198
+ raise ( Error (sexp.pexp_loc, Env. empty, Jsx_not_enabled ))
3197
3199
3198
3200
and type_function ?in_function ~arity ~async loc attrs env ty_expected_ l
3199
3201
caselist =
@@ -4608,6 +4610,10 @@ let report_error env loc ppf error =
4608
4610
| Field_access_on_dict_type ->
4609
4611
fprintf ppf
4610
4612
" Direct field access on a dict is not supported. Use Dict.get instead."
4613
+ | Jsx_not_enabled ->
4614
+ fprintf ppf
4615
+ " Cannot compile JSX expression because JSX support is not enabled. Add \
4616
+ \" jsx\" settings to rescript.json to enable JSX support."
4611
4617
4612
4618
let report_error env loc ppf err =
4613
4619
Printtyp. wrap_printing_env env (fun () -> report_error env loc ppf err)
0 commit comments