Skip to content

Commit

Permalink
Fix and test case for Mantis bug 1978
Browse files Browse the repository at this point in the history
  • Loading branch information
ganelson committed Apr 10, 2022
1 parent 76ae1a9 commit 06272f0
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 1 deletion.
3 changes: 3 additions & 0 deletions inform7/Tests/Test Problems/PM_AmbiguitiesTooDeep.txt
@@ -0,0 +1,3 @@
Foo is a room.

When play begins: if a room encloses a room that encloses a room that encloses a room that encloses a room that encloses a room that encloses a room that encloses a room that encloses a room that encloses a room that encloses a room that encloses a room, do nothing.
@@ -0,0 +1,23 @@
Inform 7 v10.1.0 has started.
I've now read your source text, which is 55 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_AmbiguitiesTooDeep
>--> The phrase a room encloses a room that encloses a room that encloses a
room that encloses a room that encloses a room that encloses a room that
encloses a room that encloses a room that encloses a room that encloses a
room that encloses a room is too complicated for me to disentangle without
running very, very slowly as I check many ambiguities in it. There ought to
be some way to simplify things for me?
I was trying to match this phrase:
if (a room encloses a room that encloses a room that encloses a room that
encloses a room that encloses a room that encloses a room that encloses a
room that encloses a room that encloses a room that encloses a room that
encloses a room - a condition):
I recognised:
a room encloses a room that encloses a room that encloses a room that
encloses a room that encloses a room that encloses a room that encloses a
room that encloses a room that encloses a room that encloses a room that
encloses a room = a condition
Inform 7 has finished.
20 changes: 19 additions & 1 deletion inform7/values-module/Chapter 5/Dash.w
Expand Up @@ -828,8 +828,26 @@ later rules can override earlier ones but still make use of them.
for (int i=0; i<no_of_possible_readings; i++)
LOGIF(MATCHING, "Possibility (P%d) $e\n", i, list_of_possible_readings[i]);

@ In general, it's not great for typecheckers in compilers to put an upper bound
on complexity, because although human-written code seldom hits such maxima, there's
always the possibility of mechanically-generated code which does. On the other hand,
the result of that doctrine is that a lot of modern compilers (Swift, for example)
slow to a painful crawl and allocate gigabytes of memory trying to understand
strange type constraints in two or three lines of code. So, for now at least,
let's be pragmatic.

@<Add this reading to the list of test cases@> =
if (no_of_possible_readings >= MAX_INVOCATIONS_PER_PHRASE) internal_error("overrun");
if (no_of_possible_readings >= MAX_INVOCATIONS_PER_PHRASE) {
THIS_IS_AN_ORDINARY_PROBLEM;
Problems::quote_wording(1, Node::get_text(p));
StandardProblems::handmade_problem(Task::syntax_tree(), _p_(PM_AmbiguitiesTooDeep));
Problems::issue_problem_segment(
"The phrase %1 is too complicated for me to disentangle without "
"running very, very slowly as I check many ambiguities in it. There "
"ought to be some way to simplify things for me?");
Problems::issue_problem_end();
return NEVER_MATCH;
}
list_of_possible_readings[no_of_possible_readings++] = alt;
Dash::clear_flags(alt);

Expand Down

0 comments on commit 06272f0

Please sign in to comment.