From 78349cc4b8144b343ddcf2b7a2a86185bf980bb3 Mon Sep 17 00:00:00 2001 From: Etienne Millon Date: Tue, 11 Apr 2023 18:03:00 +0200 Subject: [PATCH] Fix add_let --- src/lib/uTop_main.ml | 22 ++++++---------------- 1 file changed, 6 insertions(+), 16 deletions(-) diff --git a/src/lib/uTop_main.ml b/src/lib/uTop_main.ml index 9446d8d..be68c4d 100644 --- a/src/lib/uTop_main.ml +++ b/src/lib/uTop_main.ml @@ -705,22 +705,12 @@ let rewrite phrase = let add_let binding_name def = let open Parsetree in match def with - | { pstr_desc = Pstr_eval (expr, attr); pstr_loc } -> - { - pstr_loc; - pstr_desc = Pstr_value (Asttypes.Nonrecursive, [ - { - 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; - }]); - } + | { pstr_desc = Pstr_eval (expr, attrs); pstr_loc = loc } -> + Ast_helper.Str.value ~loc Nonrecursive + [ + let pat = Ast_helper.Pat.var ~loc { txt = binding_name; loc } in + Ast_helper.Vb.mk ~loc ~attrs pat expr + ] | _ -> def