Understand bug found?

Before I report this as a bug, perhaps there is a common fix or a misunderstanding on my part.

A mat is in the cottage yard. "[if steel key is nowhere]A bruised horse-hair mat lies in front of the door.[end if]".
Description of mat is "A horse-hair mat for wiping your feet so you won't track mud inside."

Understand "move mat" as looking under mat.

I know that the Move action requires a destination object, but too many of my testers want to ‘move mat’ to look for a key. They should use ‘Look under mat’ instead, but…

I get the following error when I try to compile:
Problem. An internal error has occurred: unowned. The current sentence is ‘Understand “move mat” as looking under mat’ ; the error was detected at line 886 of “inform7/if-module/Chapter 5/Understand Sentences.w”. This should never happen, and I am now halting in abject failure.

What has happened here is that one of the checks Inform carries out internally, to see if it is working properly, has failed. There must be a bug in this copy of Inform. It may be worth checking whether you have the current, up-to-date version. If so, please report this problem via Bugs | Inform 7.

As for fixing your source text to avoid this bug, the last thing you changed is probably the cause, if there is a simple cause. Your source text might in fact be wrong, and the problem might be occurring because Inform has failed to find a good way to say so. But even if your source text looks correct, there are probably rephrasings which would achieve the same effect.

1 Like

The bug should be reported for sure, although I can’t reproduce it in my (old) version of Inform. Check if you’re using the latest version, and if so, it’s good to report it.

In the version of Inform I have, ‘move mat’ gets translated as ‘push mat’. So you could write the following:

Instead of pushing the mat:
	try looking under the mat;

and that should work (without the ‘understand’ line).

1 Like

I’m using Inform 10.1.2 and I do see this. Here’s what I first tried:

The Cottage Yard is a room.

A mat is in the Cottage Yard.

Test me with "actions / move mat".

That leads to:

Cottage Yard
You can see a mat here.

>test me

>[1] actions
Actions listing on.

>[2] move mat
[pushing the mat]
Nothing obvious happens.
[pushing the mat - succeeded

Note that it redirects to “pushing.” I then put in your Understand line:

The Cottage Yard is a room.

A mat is in the Cottage Yard.

Understand "move mat" as looking under mat.

Test me with "actions / move mat".

That failed the same way you are reporting. I tried this:

Understand "move [something]" as looking under.

And that “worked” in that it redirected to the pushing command. Note that I had to do “[something]”. I couldn’t do this:

Understand "move mat" as looking under.

That didn’t cause an error but since the command redirects to “pushing” it says:

>[2] move mat
You must supply a noun

If I did this:

Understand the command "move" as something new.
Understand "move [something]" as looking under.

Test me with "actions / move mat".

That then led to an actual looking under being performed:

>[2] move mat
[looking under the mat]
You find nothing of interest.

[looking under the mat - succeeded]

But, of course, that means the move command will now never be redirected to pushing.

The minimal example of this bug in the 10.1.2 compiler appears to be

Understand “<any text>” as <a valid action name taking a noun> <any object>


Lab is a room.

Understand "xyzzy" as examining Lab.

Rather than failing the compiler, this should give the following error message:

Problem. You wrote ‘Understand “xyzzy” as examining the Lab’ but ‘understand … as …’ should be followed by a meaning, which might be an action (e.g., ‘understand “take [something]” as taking’), a thing (‘understand “stove” as the oven’) or more generally a value (‘understand “huitante” as 80’), or a named token for use in further grammar (‘understand “near [something]” as “[location phrase]”’). Also, the meaning needs to be precise, so ‘understand “x” as a number’ is not allowed - it does not say which number.

See the manual: 17.1 > 17.1. Understand

… and this is what happens if compiling for Ver 9.3/6M62, or if you substitute something other than <an object> after the action name in Ver 10.1.2, (or the name of an action that takes no noun, such as ‘jumping’).

To be specific, the correct syntax here is

Understand “<any text>” as <a valid action name>

and ‘looking under mat’ is not a valid action name- ‘looking under’ is the action name, we can’t specify exactly what the thing to be looked under is in the ‘as …ing’ clause of the declaration. We must do it in the first part, like this:

Understand "move [mat]" as looking under.

by creating a noun token [mat] that will match the mat object and only the mat object (by the name ‘mat’ or any other name we choose to give it*).

This Understand phrase adds a line to the grammar of ‘move’ that will match only with the mat and nothing else, producing a ‘looking under’ action on the mat.

You can see this by typing the debugging command ‘showverb move’, which gives the following output:

You can see a mat here.

>showverb move
Verb ‘clear’ ‘move’ ‘press’ ‘push’ ‘shift’
* noun=Routine(220967) → LookUnder
* noun → Push
* noun noun=Routine(220843) → PushDir
* noun ‘to’ noun=Routine(220880) → PushDir

Routine(220967) is the I6 representation of the [mat] token we created, the * means ‘any of the command verbs listed above’

so, to translate the first line of our new grammar for ‘move’

'match any of these command verbs followed by a name that matches the mat, to produce a ‘looking under’ action with the mat as the noun.

By which we can see that typing ‘clear mat’ or ‘push mat’ or ‘shift mat’ or ‘press mat’ will all also produce the action ‘looking under the mat’.

Also, if we type ‘move <anything other than the mat>’ the first line of grammar won’t match, and the parser will go on to try all the usual meanings of ‘move’ below it, starting with ‘pushing’.

Having said all that, restricting what can be matched by the parser like this is generally not a good idea, as you have little control over the responses to inputs that don’t work, since these are generated by the parser itself. Better to allow the parser to match a wide range of inputs, generate an action, then trap the one(s) you are interested in in Before or Instead rules:

Before pushing the mat: try looking under the mat instead.

will do what you originally intended in the simplest way.

NB here we can write ‘pushing the mat’, specifying the noun, because in the preamble to a Before rule we can use a full action pattern, which might be as complex as ‘pushing the mat in the Lab when the moon is full for the third time’ not simply an action name (which would have to be be plain ‘pushing’)

* e.g. by Understand "rug" or "Oriental carpet" as the mat.