Skip to content

Commit 6fb5eb7

Browse files
committed
[TC] dummy clauses are local to sections
This aims to solve the compilation error produced by the compilation of ``` Module foo. Class B (i : nat). Section s. (* Class with coercion depending on section parameters *) Context (A : Type). Class C (i : A) : Set := { x (x : A) :: B 3 }. End s. End foo. ```
1 parent d630d16 commit 6fb5eb7

File tree

3 files changed

+27
-3
lines changed

3 files changed

+27
-3
lines changed

apps/tc/elpi/tc_aux.elpi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ namespace tc {
158158

159159
pred remove-clause i:string.
160160
remove-clause ClauseName :-
161-
add-tc-db _ (replace ClauseName) dummy.
161+
@local! => add-tc-db _ (replace ClauseName) dummy.
162162

163163
% [section-var->decl.aux L R] auxiliary function for `section-var->decl`
164164
pred section-var->decl.aux i:list constant, o:list prop.

apps/tc/tests/test_coercion.v

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,3 +67,26 @@ Module Vehicle.
6767
Qed.
6868

6969
End Vehicle.
70+
71+
Module foo.
72+
Class B (i : nat).
73+
74+
Section s.
75+
(* Class with coercion depending on section parameters *)
76+
Context (A : Type).
77+
Class C (i : nat) : Set := {
78+
f (x : A) :: B i
79+
}.
80+
End s.
81+
End foo.
82+
83+
Module foo1.
84+
Class B (i : nat).
85+
86+
Section s.
87+
(* Class with coercion not depending on section parameters *)
88+
Class C (i : nat) : Set := {
89+
f :: B i
90+
}.
91+
End s.
92+
End foo1.

apps/tc/theories/tc.v

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,10 +86,11 @@ Elpi Accumulate lp:{{
8686
Class Bird := IsAnimal :> Animal.
8787
```
8888
The instance IsAnimal of type Bird -> Animal, is compiled before the
89-
predicate for Bird; hence, Bird is not recognize as a premise of IsAnimal.
89+
predicate for Bird; hence, it is not possible to add the premise
90+
tc-Bird for the IsAnimal instance...
9091
This problem is due to the order in which the registers for Instance and
9192
Class creation are run.
92-
The solution is to do the following two jobs when a class C is created:
93+
The solution is to do the following jobs when a class C is created:
9394
1: for every projection P of C, if P is a coercion, the wrongly
9495
compiled instance is replaced with a `dummy` clause.
9596
2: the predicate for the class is created

0 commit comments

Comments
 (0)