@@ -84,6 +84,8 @@ type error =
8484 | Field_not_optional of string * type_expr
8585 | Type_params_not_supported of Longident .t
8686 | Field_access_on_dict_type
87+ | Jsx_not_enabled
88+
8789exception Error of Location. t * Env. t * error
8890exception Error_forward of Location. error
8991
@@ -184,7 +186,7 @@ let iter_expression f e =
184186 | Pexp_pack me -> module_expr me
185187 | Pexp_await _ -> assert false (* should be handled earlier *)
186188 | 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 ))
188190 and case {pc_lhs = _ ; pc_guard; pc_rhs} =
189191 may expr pc_guard;
190192 expr pc_rhs
@@ -3193,7 +3195,7 @@ and type_expect_ ~context ?in_function ?(recarg = Rejected) env sexp ty_expected
31933195 raise (Error_forward (Builtin_attributes. error_of_extension ext))
31943196 | Pexp_await _ -> (* should be handled earlier *) assert false
31953197 | 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 ))
31973199
31983200and type_function ?in_function ~arity ~async loc attrs env ty_expected_ l
31993201 caselist =
@@ -4608,6 +4610,10 @@ let report_error env loc ppf error =
46084610 | Field_access_on_dict_type ->
46094611 fprintf ppf
46104612 " 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."
46114617
46124618let report_error env loc ppf err =
46134619 Printtyp. wrap_printing_env env (fun () -> report_error env loc ppf err)
0 commit comments