Skip to content

Commit

Permalink
Fix for Mantis bug 1821
Browse files Browse the repository at this point in the history
  • Loading branch information
ganelson committed Apr 14, 2022
1 parent bb0508e commit 6075e58
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 0 deletions.
2 changes: 2 additions & 0 deletions inform7/Tests/Test Problems/PM_KindsCircular2.txt
@@ -0,0 +1,2 @@
Blor is a kind.
Blor is a kind of blor.
@@ -0,0 +1,9 @@
Inform 7 v10.1.0 has started.
I've now read your source text, which is 10 words long.
I've also read Basic Inform by Graham Nelson, which is 7691 words long.
I've also read English Language by Graham Nelson, which is 2328 words long.
I've also read Standard Rules by Graham Nelson, which is 32132 words long.
Problem__ PM_KindsCircular2
>--> You wrote 'Blor is a kind of blor' (source text, line 2), but that seems
to make a blor a kind of itself, which cannot make sense.
Inform 7 has finished.
11 changes: 11 additions & 0 deletions inform7/core-module/Chapter 2/Kinds Problems.w
Expand Up @@ -71,6 +71,17 @@ void KindsProblems::kinds_problem_handler(int err_no, parse_node *pn, text_strea
"other.");
Problems::issue_problem_end();
break;
case KindsCircular2_KINDERROR:
Problems::quote_source(1, current_sentence);
Problems::quote_source(2, pn);
Problems::quote_kind(3, K1);
Problems::quote_kind(4, K2);
StandardProblems::handmade_problem(Task::syntax_tree(), _p_(PM_KindsCircular2));
Problems::issue_problem_segment(
"You wrote %1, but that seems to make %3 a kind of itself, which "
"cannot make sense.");
Problems::issue_problem_end();
break;
case LPCantScaleYet_KINDERROR:
StandardProblems::sentence_problem(Task::syntax_tree(), _p_(PM_LPCantScaleYet),
"this tries to scale up or down a value which so far has no point of "
Expand Down
4 changes: 4 additions & 0 deletions services/kinds-module/Chapter 1/Kinds Module.w
Expand Up @@ -86,6 +86,7 @@ to some routine of her own, gazumping this one.
@e DimensionsInconsistent_KINDERROR
@e KindUnalterable_KINDERROR
@e KindsCircular_KINDERROR
@e KindsCircular2_KINDERROR
@e LPCantScaleYet_KINDERROR
@e LPCantScaleTwice_KINDERROR
@e NeptuneError_KINDERROR
Expand Down Expand Up @@ -122,6 +123,9 @@ void KindsModule::problem_handler(int err_no, parse_node *pn, text_stream *E,
case KindsCircular_KINDERROR:
Errors::with_text("making this subkind would lead to a circularity: %S", text);
break;
case KindsCircular2_KINDERROR:
Errors::with_text("making this subkind would a kind being its own subkind: %S", text);
break;
case LPCantScaleYet_KINDERROR:
Errors::with_text("tries to scale a value with no point of reference: %S", text);
break;
Expand Down
6 changes: 6 additions & 0 deletions services/kinds-module/Chapter 2/Kinds.w
Expand Up @@ -498,6 +498,12 @@ void Kinds::make_subkind(kind *sub, kind *super) {
}

void Kinds::make_subkind_inner(kind *sub, kind *super) {
if (Kinds::eq(super, sub)) {
if (problem_count == 0)
KindsModule::problem_handler(KindsCircular2_KINDERROR,
Kinds::Behaviour::get_superkind_set_at(sub), NULL, super, sub);
return;
}
kind *K = super;
while (K) {
if (Kinds::eq(K, sub)) {
Expand Down

0 comments on commit 6075e58

Please sign in to comment.