Skip to content

Commit 76b7307

Browse files
committed
Fix renaming of exceptions
1 parent d1d5988 commit 76b7307

5 files changed

Lines changed: 20 additions & 9 deletions

File tree

src/ecParser.mly

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3608,6 +3608,7 @@ clone_rename_kind:
36083608
| TYPE { `Type }
36093609
| OP { `Op }
36103610
| PRED { `Pred }
3611+
| EXCEPTION { `Exn }
36113612
| LEMMA { `Lemma }
36123613
| MODULE { `Module }
36133614
| MODULE TYPE { `ModType }

src/ecParsetree.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1172,7 +1172,7 @@ type theory_cloning = {
11721172
}
11731173

11741174
and theory_renaming_kind =
1175-
[ `Lemma | `Op | `Pred | `Type | `Module | `ModType | `Theory]
1175+
[ `Lemma | `Op | `Pred | `Exn | `Type | `Module | `ModType | `Theory ]
11761176

11771177
and theory_renaming =
11781178
(theory_renaming_kind list * string located pair)

src/ecThCloning.ml

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,7 @@ and rk_categories = {
214214
rkc_lemmas : bool;
215215
rkc_ops : bool;
216216
rkc_preds : bool;
217+
rkc_exns : bool;
217218
rkc_types : bool;
218219
rkc_module : bool;
219220
rkc_modtype : bool;
@@ -230,7 +231,7 @@ type octxt = {
230231
module Renaming : sig
231232
val rename1 : octxt -> theory_renaming -> renaming
232233
end = struct
233-
let rename1 oc (k, (r1, r2)) : renaming =
234+
let rename1 oc ((k : theory_renaming_kind list), (r1, r2)) : renaming =
234235
let e1 =
235236
try EcRegexp.regexp (unloc r1)
236237
with EcRegexp.Error _ -> clone_error oc.oc_env (CE_InvalidRE (unloc r1)) in
@@ -253,14 +254,15 @@ end = struct
253254
| `Type -> { rk with rkc_types = true; }
254255
| `Op -> { rk with rkc_ops = true; }
255256
| `Pred -> { rk with rkc_preds = true; }
257+
| `Exn -> { rk with rkc_exns = true; }
256258
| `Module -> { rk with rkc_module = true; }
257259
| `ModType -> { rk with rkc_modtype = true; }
258260
| `Theory -> { rk with rkc_theory = true; } in
259261

260262
let init = {
261-
rkc_lemmas = false; rkc_types = false; rkc_ops = false;
262-
rkc_preds = false; rkc_module = false; rkc_modtype = false;
263-
rkc_theory = false; } in
263+
rkc_lemmas = false; rkc_types = false; rkc_ops = false;
264+
rkc_preds = false; rkc_exns = false; rkc_module = false;
265+
rkc_modtype = false; rkc_theory = false; } in
264266

265267
`Selected (List.fold_left update init k)
266268

@@ -275,6 +277,7 @@ let rename ((rk, (rex, itempl)) : renaming) (k, x) =
275277
| `Selected { rkc_lemmas = true }, `Lemma -> true
276278
| `Selected { rkc_ops = true }, `Op -> true
277279
| `Selected { rkc_preds = true }, `Pred -> true
280+
| `Selected { rkc_exns = true }, `Exn -> true
278281
| `Selected { rkc_types = true }, `Type -> true
279282
| `Selected { rkc_module = true }, `Module -> true
280283
| `Selected { rkc_modtype = true }, `ModType -> true

src/ecThCloning.mli

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ and rk_categories = {
102102
rkc_lemmas : bool;
103103
rkc_ops : bool;
104104
rkc_preds : bool;
105+
rkc_exns : bool;
105106
rkc_types : bool;
106107
rkc_module : bool;
107108
rkc_modtype : bool;

src/ecTheoryReplay.ml

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,8 @@ let xnpath ove x =
364364
(EcPath.fromqsymbol (snd ove.ovre_prefix, x))
365365

366366
(* -------------------------------------------------------------------- *)
367-
let string_of_renaming_kind = function
367+
let string_of_renaming_kind (rkind : theory_renaming_kind) =
368+
match rkind with
368369
| `Lemma -> "lemma"
369370
| `Op -> "operator"
370371
| `Pred -> "predicate"
@@ -388,7 +389,7 @@ let rename ove subst (kind, name) =
388389
match kind with
389390
| `Lemma | `Type ->
390391
EcIo.is_sym_ident newname
391-
| `Op | `Pred ->
392+
| `Op | `Pred | `Exn ->
392393
EcIo.is_op_ident newname
393394
| `Module | `ModType | `Theory ->
394395
EcIo.is_mod_ident newname
@@ -522,9 +523,14 @@ and replay_opd (ove : _ ovrenv) (subst, ops, proofs, scope) (import, x, oopd) =
522523
let scenv = ove.ovre_hooks.henv scope in
523524
let env = EcSection.env scenv in
524525

526+
let rk =
527+
match oopd.op_kind with
528+
| OB_oper (Some (OP_Exn _)) -> `Exn
529+
| _ -> `Op in
530+
525531
match Msym.find_opt x ove.ovre_ovrd.evc_ops with
526532
| None ->
527-
let (subst, x) = rename ove subst (`Op, x) in
533+
let (subst, x) = rename ove subst (rk, x) in
528534
let oopd = EcSubst.subst_op subst oopd in
529535
(subst, ops, proofs, ove.ovre_hooks.hadd_item scope ~import (Th_operator (x, oopd)))
530536

@@ -598,7 +604,7 @@ and replay_opd (ove : _ ovrenv) (subst, ops, proofs, scope) (import, x, oopd) =
598604
in
599605
match opmode with
600606
| `Alias ->
601-
let subst, x = rename ove subst (`Op, x) in
607+
let subst, x = rename ove subst (rk, x) in
602608
(newop, subst, x, true)
603609

604610
| `Inline _ ->

0 commit comments

Comments
 (0)