Skip to content

Commit

Permalink
Fix and test case for Mantis bug 2070
Browse files Browse the repository at this point in the history
  • Loading branch information
ganelson committed Apr 7, 2022
1 parent 07660ac commit 1987a34
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 10 deletions.
16 changes: 16 additions & 0 deletions inform7/Tests/Test Problems/PM_LoopWithoutBody.txt
@@ -0,0 +1,16 @@
Lab is a room.

Explaining is an action out of world applying to one topic.
Understand "explain [text]" as explaining.

Report explaining:
let L be the topic understood;
repeat with I running from 1 to the number of rows in the Table of Explanations;
choose row I in the Table of Explanations;
if there is a subject entry:
if L is the subject entry:
say "Explanation here."

Table of Explanations
subject (text)
"bug"
11 changes: 11 additions & 0 deletions inform7/Tests/Test Problems/_Results_Ideal/PM_LoopWithoutBody.txt
@@ -0,0 +1,11 @@
Inform 7 v10.1.0 has started.
I've now read your source text, which is 73 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_LoopWithoutBody
>--> You wrote 'repeat with I running from 1 to the number of rows in the
Table of Explanations' (source text, line 8): but there doesn't seem to be
any body to this phrase, in the way that a 'repeat', 'if' or 'while' is
expected to have.
Inform 7 has finished.
18 changes: 11 additions & 7 deletions inform7/imperative-module/Chapter 3/Code Blocks.w
Expand Up @@ -134,7 +134,7 @@ void CodeBlocks::beginning_block_phrase(control_structure_phrase *csp) {
CodeBlocks::pop_stack();
}
CodeBlocks::prepush_stack();
@<Construct the next phrase block@>;
if (block_being_opened) @<Construct the next phrase block@>;
}

@ In the case of a repeat through a Table, we need to create two loop
Expand All @@ -153,12 +153,16 @@ the loop begins, and pull them again when it finishes.
@ Slightly later on, we know these:

=
void CodeBlocks::attach_back_schema(inter_schema *I, csi_state CSIS) {
block_being_opened->switch_val = NULL;
if (Invocations::get_no_tokens(CSIS.inv) > 0)
block_being_opened->switch_val = CSIS.tokens->token_vals[0];
block_being_opened->tail_schema = I;
block_being_opened->compilation_state = CSIS;
int CodeBlocks::attach_back_schema(inter_schema *I, csi_state CSIS) {
if (block_being_opened) {
block_being_opened->switch_val = NULL;
if (Invocations::get_no_tokens(CSIS.inv) > 0)
block_being_opened->switch_val = CSIS.tokens->token_vals[0];
block_being_opened->tail_schema = I;
block_being_opened->compilation_state = CSIS;
return TRUE;
}
return FALSE;
}

@ At this next stage, the preliminary code for the loop (if it's a loop)
Expand Down
13 changes: 10 additions & 3 deletions inform7/imperative-module/Chapter 5/Compile Invocations Inline.w
Expand Up @@ -73,10 +73,17 @@ int CSIInline::csi_inline(value_holster *VH, parse_node *inv, source_location *w
@<Create any new local variables explicitly called for@>;
CSIInline::from_schema(idb->head_of_defn->at,
CompileImperativeDefn::get_front_schema(idb), &CSIS);
if (IDTypeData::block_follows(idb))
CodeBlocks::attach_back_schema(CompileImperativeDefn::get_back_schema(idb), CSIS);
else
if (IDTypeData::block_follows(idb)) {
if (CodeBlocks::attach_back_schema(
CompileImperativeDefn::get_back_schema(idb), CSIS) == FALSE) {
StandardProblems::sentence_problem(Task::syntax_tree(),
_p_(PM_LoopWithoutBody),
"there doesn't seem to be any body to this phrase",
"in the way that a 'repeat', 'if' or 'while' is expected to have.");
}
} else {
@<Release any my-variables created inline@>;
}
return idb->compilation_data.inline_mor;
}

Expand Down

0 comments on commit 1987a34

Please sign in to comment.