Skip to content

Commit db76103

Browse files
authored
Merge pull request #479 from math-comp/fix-error-missing-key
specific error for missing subject
2 parents 7ab245f + a84fda4 commit db76103

File tree

4 files changed

+19
-3
lines changed

4 files changed

+19
-3
lines changed

HB/instance.elpi

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,13 +57,17 @@ declare-const Name BodySkel TyWPSkel CSL :- std.do! [
5757
UnfoldClauses => copy SectionTy SectionTyUnfolded,
5858
]) (SectionTy = SectionTyUnfolded),
5959

60+
% call HB.instance TheType TheFactory
61+
std.drop NParams Args [TheType|_],
62+
63+
if (var TheType)
64+
(coq.error "HB: The instance subject must be explicitly given.\nUse:\n HB.instance Definition _ : M <subject> := ...\n HB.instance Definition _ := M.Build <subject> ...")
65+
true,
66+
6067
log.coq.env.add-const-noimplicits-failondup RealName OptimizedBody
6168
SectionTyUnfolded @transparent! C,
6269
TheFactory = (global (const C)),
6370

64-
% call HB.instance TheType TheFactory
65-
std.drop NParams Args [TheType|_],
66-
6771
private.check-non-forgetful-inheritance TheType Factory,
6872

6973
private.declare-instance Factory TheType TheFactory Clauses CSL,

Makefile.test-suite.coq.local

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ DIFF=\
1818
fi
1919

2020
post-all::
21+
$(call DIFF, tests/err_missin_subject.v)
2122
$(call DIFF, tests/compress_coe.v)
2223
$(call DIFF, tests/about.v)
2324
$(call DIFF, tests/howto.v)

tests/err_missin_subject.v

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
From HB Require Import structures.
2+
HB.mixin Record M X := {}.
3+
HB.structure Definition S := { X of M X}.
4+
HB.instance Definition _ : M nat := M.Build _.
5+
HB.instance Definition _ : M _ := M.Build bool.
6+
Fail HB.instance Definition _ : M _ := M.Build _.

tests/err_missin_subject.v.out

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
The command has indeed failed with message:
2+
HB: The instance subject must be explicitly given.
3+
Use:
4+
HB.instance Definition _ : M <subject> := ...
5+
HB.instance Definition _ := M.Build <subject> ...

0 commit comments

Comments
 (0)