Skip to content

Commit dee7267

Browse files
committed
Improve missing join error message
Fixes #349
1 parent cc1b306 commit dee7267

File tree

2 files changed

+13
-9
lines changed

2 files changed

+13
-9
lines changed

HB/common/database.elpi

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -223,21 +223,24 @@ distinct-pairs-below CurrentClass AllSuper C1 C2 :-
223223
not(sub-class? C1 C2),
224224
not(sub-class? C2 C1),
225225
if (join C1n C2n C3n)
226-
(assert-building-bottom-up CurrentClass C3n, fail) % a join, not a valid pair
226+
(assert-building-bottom-up CurrentClass C3n C1n C2n, fail) % a join, not a valid pair
227227
true, % no join, valid pair
228228
].
229229

230-
pred assert-building-bottom-up i:class, i:classname.
231-
assert-building-bottom-up CurrentClass C3n :-
230+
pred assert-building-bottom-up i:class, i:classname, i:classname, i:classname.
231+
assert-building-bottom-up CurrentClass C3n C1n C2n :-
232232
class-def (class C3n X Y),
233233
CurrentClass = class CC _ _,
234234
if (not (sub-class? CurrentClass (class C3n X Y)))
235235
(gref->modname CC 1 "." Before, gref->modname_short C3n "." After,
236-
Msg1 is "- declare structure " ^ Before ^ " before structure " ^ After ^ ";",
237-
coq.error "You must declare the hierarchy bottom-up."
236+
Msg1 is "- declare structure " ^ Before ^ " before structure " ^ After ^ " if " ^ After ^ " inherits from it;",
237+
Msg2 is "- declare an additional structure that inherits from both "
238+
^ {gref->modname_short C1n "."} ^ " and " ^ {gref->modname_short C2n "."}
239+
^ " and from which " ^ Before ^ " and/or " ^ After ^ " inherit.",
240+
coq.error "You must declare the hierarchy bottom-up or addd a missing join."
238241
"There are two ways out:"
239242
Msg1
240-
"- declare an additional structure from which both inherit")
243+
Msg2)
241244
true.
242245

243246
pred distinct-pairs_pair i:prop, o:pair class class.

tests/missing_join_error.v.out

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
The command has indeed failed with message:
2-
You must declare the hierarchy bottom-up. There are two ways out:
3-
- declare structure A2B1 before structure B2A1;
4-
- declare an additional structure from which both inherit
2+
You must declare the hierarchy bottom-up or addd a missing join.
3+
There are two ways out:
4+
- declare structure A2B1 before structure B2A1 if B2A1 inherits from it;
5+
- declare an additional structure that inherits from both A1 and A2 and from which A2B1 and/or B2A1 inherit.

0 commit comments

Comments
 (0)