@@ -4663,13 +4663,21 @@ let unify_exp ?sdesc_for_hint env exp expected_ty =
4663
4663
with Error (loc , env , Expr_type_clash(err , tfc , None)) ->
4664
4664
raise (Error (loc, env, Expr_type_clash (err, tfc, sdesc_for_hint)))
4665
4665
4666
+ let is_exclave_extension_node = function
4667
+ | "extension.exclave" | "ocaml.exclave" | "exclave" -> true
4668
+ | _ -> false
4669
+
4666
4670
(* If [is_inferred e] is true, [e] will be typechecked without using
4667
4671
the "expected type" provided by the context. *)
4668
4672
4669
4673
let rec is_inferred sexp =
4670
4674
match Jane_syntax.Expression. of_ast sexp with
4671
4675
| Some (jexp , _attrs ) -> is_inferred_jane_syntax jexp
4672
4676
| None -> match sexp.pexp_desc with
4677
+ | Pexp_apply
4678
+ ({ pexp_desc = Pexp_extension ({ txt }, PStr [] ) },
4679
+ [Nolabel , sbody]) when is_exclave_extension_node txt ->
4680
+ is_inferred sbody
4673
4681
| Pexp_ident _ | Pexp_apply _ | Pexp_field _ | Pexp_constraint _
4674
4682
| Pexp_coerce _ | Pexp_send _ | Pexp_new _ -> true
4675
4683
| Pexp_sequence (_ , e ) | Pexp_open (_ , e ) -> is_inferred e
@@ -5345,9 +5353,8 @@ and type_expect_
5345
5353
in
5346
5354
{exp with exp_loc = loc}
5347
5355
| Pexp_apply
5348
- ({ pexp_desc = Pexp_extension ({
5349
- txt = " extension.exclave" | " ocaml.exclave" | " exclave" as txt}, PStr [] ) },
5350
- [Nolabel , sbody]) ->
5356
+ ({ pexp_desc = Pexp_extension ({ txt }, PStr [] ) },
5357
+ [Nolabel , sbody]) when is_exclave_extension_node txt ->
5351
5358
if (txt = " extension.exclave" ) && not (Language_extension. is_enabled Mode ) then
5352
5359
raise (Typetexp. Error (loc, Env. empty, Unsupported_extension Mode ));
5353
5360
begin
0 commit comments