Skip to content

Commit

Permalink
[TC] bug fix: conversion str2gr should not be done in the cache
Browse files Browse the repository at this point in the history
this avoids a bug source reproducible with tests/test_import/f2.v
  • Loading branch information
FissoreD committed Jul 1, 2024
1 parent f15c687 commit ae73476
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 14 deletions.
28 changes: 14 additions & 14 deletions apps/tc/src/coq_elpi_class_tactics_takeover.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1580,7 +1580,8 @@ module type M = sig
val add : elt -> t -> t
val gr2elt : Names.GlobRef.t -> elt
val mem : elt -> t -> bool
val strs2set : Libnames.qualid list -> t
val of_qualid_list : Libnames.qualid list -> t

end

(* Set of overridden class *)
Expand All @@ -1596,11 +1597,9 @@ module OSet : M = struct
let mem = M.mem
let gr2elt (x: Names.GlobRef.t) : elt = x

let strs2set x =
let add_str x = add (str2gr x) in
let grl2set grl = List.fold_right add_str grl empty in
grl2set x

let of_qualid_list (x: Libnames.qualid list) : t =
let add s x = add (Coq_elpi_utils.locate_simple_qualid x) s in
List.fold_left add empty x
end

module Modes = struct
Expand All @@ -1612,8 +1611,8 @@ module Modes = struct

type action =
| Set of omode
| Add of Libnames.qualid list
| Rm of Libnames.qualid list
| Add of OSet.t
| Rm of OSet.t

let omodes = ref (CSMap.empty : omode CSMap.t)

Expand All @@ -1627,10 +1626,10 @@ module Modes = struct
let new_mode =
match old_mode, new_mode with
| _, Set(mode) -> mode
| AllButFor s, Add grl -> AllButFor (OSet.diff s (OSet.strs2set grl))
| AllButFor s, Rm grl -> AllButFor (OSet.union s (OSet.strs2set grl))
| Only s, Add grl -> Only (OSet.union s (OSet.strs2set grl))
| Only s, Rm grl -> Only (OSet.diff s (OSet.strs2set grl))
| AllButFor s, Add grl -> AllButFor (OSet.diff s grl)
| AllButFor s, Rm grl -> AllButFor (OSet.union s grl)
| Only s, Add grl -> Only (OSet.union s grl)
| Only s, Rm grl -> Only (OSet.diff s grl)
in
omodes := CSMap.set name new_mode !omodes

Expand Down Expand Up @@ -1695,17 +1694,18 @@ end


let set_solver_mode kind qname (l: Libnames.qualid list) =
let l = OSet.of_qualid_list l in
let cache_solver_mode = Modes.cache_solver_mode in
match kind with
| AAdd -> Lib.add_leaf (cache_solver_mode (qname, Add l, false))
| ARm -> Lib.add_leaf (cache_solver_mode (qname, Rm l, false))
| AAll -> Lib.add_leaf (cache_solver_mode (qname, Set (AllButFor OSet.empty), false))
| ANone-> Lib.add_leaf (cache_solver_mode (qname, Set (Only OSet.empty), false))
| ASet -> Lib.add_leaf (cache_solver_mode (qname, Set (Only (OSet.strs2set l)), false))
| ASet -> Lib.add_leaf (cache_solver_mode (qname, Set (Only l), false))

let solver_register l =
Lib.add_leaf (Solver.cache_solver (l, Create));
Lib.add_leaf (Modes.cache_solver_mode (l, Add [], true))
Lib.add_leaf (Modes.cache_solver_mode (l, Add OSet.empty, true))

let solver_activate l = Lib.add_leaf (Solver.cache_solver (l, Activate))

Expand Down
4 changes: 4 additions & 0 deletions apps/tc/tests/test_import/f1.v
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
From elpi.apps Require Export tc.
From Coq Require Export Morphisms.

Elpi TC Solver Override TC.Solver Rm Proper ProperProxy.
1 change: 1 addition & 0 deletions apps/tc/tests/test_import/f2.v
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
From elpi.apps.tc.tests.test_import Require Import f1.

0 comments on commit ae73476

Please sign in to comment.