Skip to content

Commit

Permalink
Enforce correct database initialisation.
Browse files Browse the repository at this point in the history
The `Elpi Db` command used to declare the database for all phases,
but only properly initialize it for the current phase. This is no
longer the case, and databases must be declared separately (or via
`#[phase="both"] Elpi Db`) for each phase.

Co-Authored-By: Jan-Oliver Kaiser <[email protected]>
  • Loading branch information
Rodolphe Lepigre and Jan-Oliver Kaiser committed Mar 11, 2024
1 parent 1b2b57e commit 445410d
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 10 deletions.
1 change: 1 addition & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

### Commands
- New `Elpi Accumulate dbname File filename` allows to accumulate a file int a db
- `Elpi Db` now only creates (and initialises) a database for the specified phase

### API
- New `coq.parse-attributes` support for the `attlabel` specification,
Expand Down
17 changes: 9 additions & 8 deletions apps/NES/theories/NES.v
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,21 @@ From elpi.apps.NES Extra Dependency "nes_interp.elpi" as nes_interp.

From elpi Require Import elpi.

#[synterp] Elpi Db NES.db lp:{{
#[phase="both"] Elpi Db NES.db lp:{{

pred open-ns o:string, o:list string.
:name "open-ns:begin"
open-ns _ _ :- fail.
typeabbrev path (list string).

:index (2)
pred ns o:path, o:modpath.

}}.

#[phase="both"] Elpi Accumulate NES.db lp:{{
#[synterp] Elpi Accumulate NES.db lp:{{

typeabbrev path (list string).
pred open-ns o:string, o:list string.
:name "open-ns:begin"
open-ns _ _ :- fail.

:index (2)
pred ns o:path, o:modpath.
}}.

Elpi Command NES.Status.
Expand Down
5 changes: 3 additions & 2 deletions src/coq_elpi_vernacular.ml
Original file line number Diff line number Diff line change
Expand Up @@ -463,10 +463,11 @@ let run_in_program ?(program = current_program ()) ?(st_setup=fun x -> x) (loc,
| None -> same_phase Interp P.stage
| Some phase -> same_phase phase P.stage in
let elpi = P.ensure_initialized () in
P.declare_db n;
if do_init then
if do_init then begin
P.declare_db n;
let unit = P.unit_from_string ~elpi loc s in
P.init_db n unit
end

let load_command = P.load_command
let load_tactic = P.load_tactic
Expand Down

0 comments on commit 445410d

Please sign in to comment.