Skip to content

Commit 49d5de9

Browse files
committed
HB.instance: failure building a class is not fatal
It may be due to a parameter being not rich enough for a mixin we were able to found during synthesis.
1 parent 7539623 commit 49d5de9

File tree

3 files changed

+31
-1
lines changed

3 files changed

+31
-1
lines changed

HB/instance.elpi

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,9 @@ infer-class T Class Struct MLwP S Name STy Clauses:- std.do![
169169
private.optimize-class-body THD {std.length Params} KCApp KCAppNames Clauses,
170170
coq.mk-app (global KS) {std.append Params [T, KCAppNames]} S,
171171
if-verbose (coq.say {header} "structure instance for" Name "is" {coq.term->string S}),
172-
std.assert-ok! (coq.typecheck S STy) "infer-class: S illtyped",
172+
173+
coq.typecheck S STy ok, % failure may be due to a parameter not rich enough see #435
174+
173175
].
174176

175177
pred decl-const-in-struct i:string, i:term, i:term, i:constant.

_CoqProject.test-suite

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

9898
tests/saturate_on.v
99+
tests/bug_435.v
99100

100101
-R tests HB.tests
101102
-R examples HB.examples

tests/bug_435.v

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
From HB Require Import structures.
2+
3+
HB.mixin Record M T := { m : bool }.
4+
HB.structure Definition S := {T of M T}.
5+
6+
HB.mixin Record A1 X T := { a1 : bool }.
7+
HB.structure Definition B1 X := {T of A1 X T}.
8+
9+
HB.instance Definition _ (X : Type) := A1.Build X unit true.
10+
11+
HB.mixin Record A2 (X : Type) T := { a2 : bool }.
12+
HB.structure Definition B2 (X : Type) := {T of A2 X T}.
13+
14+
(* This should work but fails. *)
15+
Module should_work_but_fails.
16+
HB.structure Definition B (X : S.type) := {T of A1 X T & A2 X T}.
17+
#[verbose] HB.instance Definition _ (X : Type) := A2.Build X unit true.
18+
HB.saturate unit.
19+
Check unit : B.type _.
20+
End should_work_but_fails.
21+
22+
Module workaround.
23+
HB.instance Definition _ (X : Type) := A2.Build X unit true.
24+
HB.structure Definition B (X : S.type) := {T of A1 X T & A2 X T}.
25+
HB.saturate unit.
26+
Check unit : B.type _.
27+
End workaround.

0 commit comments

Comments
 (0)