@@ -1974,6 +1974,20 @@ module Theory = struct
19741974 " end-of-file while processing proof %s" (fst scope.sc_name)
19751975
19761976 (* -------------------------------------------------------------------- *)
1977+ let require_start (scope : scope ) (thname : symbol ) (mode : thmode )
1978+ : scope =
1979+ let new_ = enter (for_loading scope) mode thname `Global in
1980+ { new_ with sc_env = EcSection. astop new_.sc_env }
1981+
1982+ let require_finish ?(old : scope option = None ) ~(new_ : scope )
1983+ (ri : required_info ) : scope =
1984+ let (cth, rqs), (name1, _), new_ = exit_r ~pempty: `No new_ in
1985+ assert (ri.rqd_name = name1);
1986+ let scope =
1987+ { (odfl new_ old) with sc_loaded =
1988+ Msym. add ri.rqd_name (oget cth, rqs) new_.sc_loaded; } in
1989+ bump_prelude (require_loaded ri scope)
1990+
19771991 let require (scope : scope ) ((name , mode ) : required_info * thmode ) loader =
19781992 assert (scope.sc_pr_uc = None );
19791993
@@ -1984,24 +1998,13 @@ module Theory = struct
19841998 end else
19851999 match Msym. find_opt name.rqd_name scope.sc_loaded with
19862000 | Some _ -> require_loaded name scope
1987-
19882001 | None ->
19892002 try
1990- let imported = enter (for_loading scope) mode name.rqd_name `Global in
1991- let imported = { imported with sc_env = EcSection. astop imported.sc_env } in
2003+ let imported = require_start scope name.rqd_name mode in
19922004 let thname = fst imported.sc_name in
19932005 let imported = loader imported in
1994-
19952006 check_end_required imported thname;
1996-
1997- let cth = exit_r ~pempty: `No imported in
1998- let (cth, rqs), (name1, _), imported = cth in
1999- assert (name.rqd_name = name1);
2000- let scope = { scope with sc_loaded =
2001- Msym. add name.rqd_name (oget cth, rqs) imported.sc_loaded; } in
2002-
2003- bump_prelude (require_loaded name scope)
2004-
2007+ require_finish ~old: (Some scope) ~new_: imported name
20052008 with e -> begin
20062009 match toperror_of_exn_r e with
20072010 | Some (l , e ) when not (EcLocation. isdummy l) ->
@@ -2112,7 +2115,7 @@ module Cloning = struct
21122115 | Some pt ->
21132116 let t = { pt_core = pt; pt_intros = [] ; } in
21142117 let t = { pl_loc = pt.pl_loc; pl_desc = Pby (Some [t]); } in
2115- let t = { pt_core = t; pt_intros = [] ; } in
2118+ let t = { pt_core = t; pt_intros = [] ; } in
21162119 let (x, ax) = axc.C. axc_axiom in
21172120
21182121 let pucflags = { puc_smt = true ; puc_local = false ; } in
0 commit comments