Skip to content

Commit 90ee6f7

Browse files
committed
HB.instance: abstract over unresolved holes (fix #447)
1 parent 49d5de9 commit 90ee6f7

File tree

3 files changed

+28
-1
lines changed

3 files changed

+28
-1
lines changed

HB/instance.elpi

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,11 @@ infer-class T Class Struct MLwP S Name STy Clauses:- std.do![
177177
pred decl-const-in-struct i:string, i:term, i:term, i:constant.
178178
decl-const-in-struct Name S STy CS:- std.do![
179179

180-
log.coq.env.add-const-noimplicits Name S STy @transparent! CS, % Bug coq/coq#11155, could be a Let
180+
if (ground_term S) (S1 = S, STy1 = STy)
181+
(abstract-holes.main S S1,
182+
std.assert-ok! (coq.typecheck S1 STy1) "HB: structure instance illtyped after generalizing over holes"),
183+
184+
log.coq.env.add-const-noimplicits Name S1 STy1 @transparent! CS, % Bug coq/coq#11155, could be a Let
181185
with-locality (log.coq.CS.declare-instance CS), % Bug coq/coq#11155, should be local
182186
acc-clause current (local-canonical CS),
183187
if-verbose (coq.say {header} "structure instance" Name "declared"),

_CoqProject.test-suite

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ tests/factory_when_notation.v
9797

9898
tests/saturate_on.v
9999
tests/bug_435.v
100+
tests/bug_447.v
100101

101102
-R tests HB.tests
102103
-R examples HB.examples

tests/bug_447.v

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
From HB Require Import structures.
2+
3+
Variant testTy := A | B.
4+
HB.mixin Record Stack1 T := { prop1 : unit }.
5+
HB.structure Definition JustStack1 := { T of Stack1 T }.
6+
HB.mixin Record Stack1Param R T := { prop2 : unit }.
7+
HB.structure Definition JustStack1Param R := { T of Stack1Param R T }.
8+
9+
HB.mixin Record Stack2 T := { prop3 : unit }.
10+
HB.structure Definition JustStack2 := { T of Stack2 T }.
11+
HB.mixin Record Mixed T of Stack1 T & Stack2 T := { prop4 : unit }.
12+
HB.structure Definition JustMixed := { T of Mixed T & Stack1 T & Stack2 T}.
13+
HB.structure Definition JustMixedParam R :=
14+
{ T of Mixed T & Stack1 T & Stack1Param R T & Stack2 T}.
15+
16+
HB.instance Definition _ := @Stack1.Build testTy tt.
17+
HB.instance Definition _ := @Stack2.Build testTy tt.
18+
19+
HB.instance Definition _ {R} := @Stack1Param.Build R testTy tt.
20+
HB.instance Definition _ := @Mixed.Build testTy tt.
21+
22+
Check testTy : JustMixedParam.type _.

0 commit comments

Comments
 (0)