Skip to content

Commit 7539623

Browse files
authored
Merge pull request #481 from math-comp/fix-error-bad-mix
improve error message on instance of not a factory
2 parents 612ccc5 + 47e8518 commit 7539623

File tree

4 files changed

+29
-2
lines changed

4 files changed

+29
-2
lines changed

HB/instance.elpi

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@ declare-const Name BodySkel TyWPSkel CSL :- std.do! [
4242

4343
% identify the factory
4444
std.assert! (coq.safe-dest-app SectionTy (global FactoryAlias) Args) "The type of the instance is not a factory",
45-
factory-alias->gref FactoryAlias Factory,
45+
if (factory-alias->gref FactoryAlias Factory) true
46+
(coq.error "HB:" {coq.term->string (global FactoryAlias)} "is not a factory or its library was not correctly imported"),
4647
std.assert! (factory-nparams Factory NParams) "Not a factory synthesized by HB",
4748

4849
% declare the constant for the factory instance

Makefile.test-suite.coq.local

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,5 @@ post-all::
2626
$(call DIFF, tests/missing_join_error.v)
2727
$(call DIFF, tests/not_same_key.v)
2828
$(call DIFF, tests/hnf.v)
29-
$(call DIFF, tests/err_miss_dep.v)
29+
$(call DIFF, tests/err_miss_dep.v)
30+
$(call DIFF, tests/err_bad_mix.v)

tests/err_bad_mix.v

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
From HB Require Import structures.
2+
3+
Module Test.
4+
HB.mixin Record Mixin T := {
5+
zero: T;
6+
}.
7+
8+
HB.structure Definition Struct := { T of Mixin T }.
9+
10+
HB.instance Definition struct_bool := Mixin.Build bool true.
11+
12+
Module Exports.
13+
HB.reexport.
14+
End Exports.
15+
End Test.
16+
(** Uncommenting any of these two prevents the issue *)
17+
(* Export Test.Exports. *)
18+
(* HB.export Test. *)
19+
20+
Fail HB.instance Definition struct_nat := Test.Mixin.Build nat 0.

tests/err_bad_mix.v.out

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Interactive Module Test started
2+
Interactive Module Exports started
3+
The command has indeed failed with message:
4+
HB: Test.Mixin.axioms_
5+
is not a factory or its library was not correctly imported

0 commit comments

Comments
 (0)