Inform 7 Interpreter Crash

I’m having a problem with the Inform 7 interpreter crashing when I use Example 374: 9 AM Appointment.

When I use the waiting more command, the command is accepted but no new command line appears.

It looks like this and I can’t do anything afterwards?

The example code seems to work well enough for me in its original form, so it must not be that.

If the interpreter only freezes itself up and doesn’t take the rest of I7 down, it sounds like you’re running into an endless (or very long) loop. Maybe something didn’t go quite right when you were adapting the code to your game. Also, just to be sure, have you tried it in a real interpreter outside of I7 to see what happens?

That was interesting, when playing it with Frotz and typing wait it stopped responding.

Should I post all my code, its 549 words?

You could, but if you can condense it any further, it would be even better.

A very simple iterative approach often works well here: just go over your code, take out anything you find that you can take out without making it impossible to compile or test, and check if the problem is still there. If it isn’t, put back what you last removed and try to remove smaller pieces of it; if it is, repeat until you really can’t remove anything more.

It looks like the error occurs when this code is being used.

The last turn's time of day is a time that varies.

When play begins:
	now the last turn's time of day is 11:58 PM;
	now the time of day is 11:59 PM.

Every turn: 
	if the time of day is less than the last turn's time of day:
		if the current day is less than last:
			now the current day is the day after the current day;
			now the last turn's time of day is the time of day;
			now the current day is the day after the current day;
			now the last turn's time of day is the time of day;
			now the current month is the month after the current month.

Note I excluded the section where I define days and months, and this code won’t compile without it.

Honestly, I think you should practice that trimming a bit more.

On one hand, the code you posted is not a short, self-contained, compilable example; not even if you combine it with Inform Example 374, “Nine AM Appointment”, since, as you note, it won’t compile without the day and month definitions.

On the other hand, it turns out that most of your code is not needed to trigger the bug. In fact, only the following lines, appended to Example 374, are needed:

When play begins: now the time of day is 11:59 PM.

Test bug with "wait 2 minutes".

Anyway, it turns out to be a bug in the example, and/or in Inform: the “carry out waiting more” doesn’t use the special time arithmetic phrases “(interval) after/before (time)” that wrap the clock around correctly, so any waiting period that skips over 12:00 AM will cause the rule to enter an infinite loop. You can fix it by replacing the “carry out waiting” rule with the following:

Carry out waiting more:
	let the time interval be the time understood minus one minute;
	let the target time be the time interval after the time of day;   [<-- this wraps around correctly]
	while the time of day is not the target time:
		follow the turn sequence rules.

You may also want to add a rule to block waiting for zero minutes, which the rule above would treat as a 24-hour wait:

Check waiting more:
	if the time understood is less than one minute, say "Feeling a bit impatient, are we?" instead.

(And yes, I really should report this as a bug in the example, except that I don’t have my password for the Inform bug tracker saved on this computer, and I can’t seem to remember it myself. Later, I guess.)

Ps. I can’t test it for the reason you noted yourself, but this line in the code you posted above looks funny:

You might want to check exactly what Inform is resolving that “last” to; it might not be what you expect.

Ok, that error has been fixed. Thank you.