1
0
Fork 0
mirror of https://github.com/ganelson/inform.git synced 2024-07-01 06:24:58 +03:00

Fix and test cases for Mantis bug 1921

This commit is contained in:
Graham Nelson 2022-04-11 16:08:37 +01:00
parent f9f68117bc
commit ea328f3f76
6 changed files with 95 additions and 11 deletions

View file

@ -1,8 +1,8 @@
100.0% in inform7 run
68.2% in compilation to Inter
47.8% in //Sequence::undertake_queued_tasks//
68.0% in compilation to Inter
47.7% in //Sequence::undertake_queued_tasks//
4.5% in //MajorNodes::pre_pass//
3.1% in //MajorNodes::pass_1//
3.2% in //MajorNodes::pass_1//
2.3% in //RTPhrasebook::compile_entries//
1.8% in //ImperativeDefinitions::assess_all//
1.5% in //RTKindConstructors::compile//
@ -18,20 +18,20 @@
0.1% in //Task::make_built_in_kind_constructors//
0.1% in //Understand::traverse//
0.1% in //World::stages_II_and_III//
2.2% not specifically accounted for
29.0% in running Inter pipeline
10.1% in step 14/15: generate inform6 -> auto.inf
2.1% not specifically accounted for
29.3% in running Inter pipeline
10.2% in step 14/15: generate inform6 -> auto.inf
7.6% in step 5/15: load-binary-kits
6.7% in step 6/15: make-synoptic-module
1.6% in step 9/15: make-identifiers-unique
6.8% in step 6/15: make-synoptic-module
1.5% in step 9/15: make-identifiers-unique
0.4% in step 12/15: eliminate-redundant-operations
0.4% in step 4/15: compile-splats
0.4% in step 7/15: shorten-wiring
0.3% in step 11/15: eliminate-redundant-labels
0.3% in step 8/15: detect-indirect-calls
0.2% in step 11/15: eliminate-redundant-labels
0.1% in step 10/15: reconcile-verbs
0.1% in step 2/15: parse-insertions
0.1% in step 3/15: resolve-conditional-compilation
0.5% not specifically accounted for
2.3% in supervisor
0.7% not specifically accounted for
2.2% in supervisor
0.4% not specifically accounted for

View file

@ -0,0 +1,4 @@
Foo is a room. Boz is a room.
Quoggle relates various things to various things.
The verb to quog means the quoggle relation.
Boz quogs the player.

View file

@ -0,0 +1,4 @@
Foo is a room. Boz is a room.
Quoggle relates various things to various things.
The verb to quog means the quoggle relation.
The player quogs Foo.

View file

@ -0,0 +1,10 @@
Inform 7 v10.1.0 has started.
I've now read your source text, which is 27 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 32092 words long.
Problem__ PM_LateLeftTermWrongKind
>--> You wrote 'Boz quogs the player' (source text, line 4), but I think the
kind of Boz is a room, and not a thing, which is what this relationship
would need it to be. (It relates a thing to a thing.)
Inform 7 has finished.

View file

@ -0,0 +1,10 @@
Inform 7 v10.1.0 has started.
I've now read your source text, which is 27 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 32092 words long.
Problem__ PM_LateRightTermWrongKind
>--> You wrote 'The player quogs Foo' (source text, line 4), but I think the
kind of Foo is a room, and not a thing, which is what this relationship
would need it to be. (It relates a thing to a thing.)
Inform 7 has finished.

View file

@ -80,6 +80,7 @@ void World::stage_IV(void) {
InferenceSubjects::check_model(infs);
@<Check that properties are permitted@>;
@<Check that properties are not contradictory@>;
@<Check that relations are permitted@>;
}
World::ask_plugins_at_stage(WORLD_STAGE_IV);
}
@ -192,6 +193,61 @@ about the Portal, to stand.
"which is impossible. When a kind's definition says that something is 'always' "
"true, there is no way to override that for particular things of the kind.");
@ This is a last line of defence. Suppose we define "to connect to" as a relation
between things and things, and then write "X connects to Y". Inform must clearly
check that X and Y are both things. It does indeed make some checks along those
lines earlier on in compilation, but there are objects whose kinds are not known
until model completion time -- in particular, there can be objects which might
be things or might be rooms, so that we cannot know if "X connects to Y" is
legal until after the model is completed.
But that's now! And so we make one last check, just in case.
@<Check that relations are permitted@> =
inference *inf;
POSITIVE_KNOWLEDGE_LOOP(inf, infs, relation_inf) {
binary_predicate *bp = RelationSubjects::to_bp(infs);
inference_subject *left_infs = NULL;
inference_subject *right_infs = NULL;
RelationInferences::get_term_subjects(inf, &left_infs, &right_infs);
instance *left_instance = InstanceSubjects::to_instance(left_infs);
instance *right_instance = InstanceSubjects::to_instance(right_infs);
kind *left_kind = Instances::to_kind(left_instance);
kind *right_kind = Instances::to_kind(right_instance);
kind *left_needed_kind = BinaryPredicates::term_kind(bp, 0);
kind *right_needed_kind = BinaryPredicates::term_kind(bp, 1);
if ((left_instance) && (Kinds::conforms_to(left_kind, left_needed_kind) == FALSE)) {
current_sentence = Inferences::where_inferred(inf);
Problems::quote_source(1, current_sentence);
Problems::quote_object(2, left_instance);
Problems::quote_kind(3, left_kind);
Problems::quote_kind(4, left_needed_kind);
Problems::quote_kind(5, right_needed_kind);
StandardProblems::handmade_problem(Task::syntax_tree(),
_p_(PM_LateLeftTermWrongKind));
Problems::issue_problem_segment(
"You wrote %1, but I think the kind of %2 is %3, and not %4, "
"which is what this relationship would need it to be. (It "
"relates %4 to %5.)");
Problems::issue_problem_end();
}
if ((right_instance) && (Kinds::conforms_to(right_kind, right_needed_kind) == FALSE)) {
current_sentence = Inferences::where_inferred(inf);
Problems::quote_source(1, current_sentence);
Problems::quote_object(2, right_instance);
Problems::quote_kind(3, right_kind);
Problems::quote_kind(4, left_needed_kind);
Problems::quote_kind(5, right_needed_kind);
StandardProblems::handmade_problem(Task::syntax_tree(),
_p_(PM_LateRightTermWrongKind));
Problems::issue_problem_segment(
"You wrote %1, but I think the kind of %2 is %3, and not %5, "
"which is what this relationship would need it to be. (It "
"relates %4 to %5.)");
Problems::issue_problem_end();
}
}
@h Stage V.
A final chance to add properties which may assist the run-time implementation
of whatever a plugin is concerned with, but which is not allowed to make