Fix add_let

This commit is contained in:
Etienne Millon 2023-04-11 18:03:00 +02:00 committed by Etienne Millon
parent 846af28b3c
commit 78349cc4b8
1 changed files with 6 additions and 16 deletions

View File

@ -705,22 +705,12 @@ let rewrite phrase =
let add_let binding_name def = let add_let binding_name def =
let open Parsetree in let open Parsetree in
match def with match def with
| { pstr_desc = Pstr_eval (expr, attr); pstr_loc } -> | { pstr_desc = Pstr_eval (expr, attrs); pstr_loc = loc } ->
{ Ast_helper.Str.value ~loc Nonrecursive
pstr_loc; [
pstr_desc = Pstr_value (Asttypes.Nonrecursive, [ let pat = Ast_helper.Pat.var ~loc { txt = binding_name; loc } in
{ Ast_helper.Vb.mk ~loc ~attrs pat expr
pvb_pat = { ]
ppat_desc = Ppat_var { txt = binding_name; loc = pstr_loc; };
ppat_loc_stack= [];
ppat_loc = pstr_loc;
ppat_attributes = [];
};
pvb_expr = expr;
pvb_attributes = attr;
pvb_loc = pstr_loc;
}]);
}
| _ -> | _ ->
def def