Possible bug in Inform 7 compiler relating to objects/kinds called X of Y?

Hi there!

The comments in the brief code below speak for themselves. I think this seems like a bug, right? Can anyone correct me or suggest what I should do? Version: Inform 7 for Windows (23rd February 2018; 6M62).

Cheers,

Ben

[The following line causes an error…]
A person has a number called a level of greatness.

A stage of unease is a kind of value. The plural of a stage of unease is stages of unease.

[… but the error can be avoided by removing the following line, which surely can’t be right.]
The stages of unease are x, y, and z.

The player is in a room called the bug-hunting room.

What is the error?

Problem. You wrote ‘A person has a number called a level of greatness’ but only an object, kind, rulebook, action or activity can be allowed to have properties or variables, so for instance ‘A door has a colour’ is fine but not ‘A number has a length’.

The error can also be avoided by moving the ‘A person has a number…’ declaration to somewhere in the source after the ‘The stages of unease are…’

Or, by removing the ‘of’ from ‘level of greatness’ i.e.

A person has a number called a level greatness.

or

A person has a number called a greatness level.

but calling the number anything including ‘of’ reproduces the error.

Unsurprisingly,

A person has a number called a level-of-greatness

also works fine.

Interestingly, you can also allocate a number called ‘level of greatness’ to the player in the first couple of lines, but not to any other kind or object, even one newly declared.

It makes a certain amount of sense. The syntax X of Y is how Inform lets you refer to property X of object Y. In any context other than a called declaration you wouldn’t actually be able to refer to a property that includes the word of (i.e. “level of greatness” would be interpreted to be the level property of the greatness object), so Inform isn’t letting you define it in the first place.

Solution: don’t do that. Use greatness level or just greatness (since “level” is implied since it’s a numeric stat anyway).

1 Like

Thanks all for the confirmation and clarification. I suspected this was because “X of Y” has some special syntactical meaning, but the compiler nevertheless tried to allow me to have a straightforward number called “X of Y”, but this attempt failed in an improper way. This seems to have been confirmed by your answers.

I think this is a small but not trivial bug. It’s easy to work around, but it’s very nice (produces clear code) in some contexts to be able to have something called “X of Y”, and when this happened to me it was very confusing and it took quite some time to understand what was happening because the two lines that together created the error were much further apart in my code than in my illustrative example. If inform7.com comes back up and I still remember, I’ll report it.

Cheers,

Ben

Except that usually Inform copes fine with ‘X of Y’ as a property name:

"__Test" by PB

A bug is an animal. It is in a room called the bug-hunting room.

A stage of unease is a kind of value. The plural of a stage of unease is stages of unease.

The stages of unease are x, y, and z.

A person has a number called a level of consistency.

When play begins:
	Now the level of consistency of the bug is 5.
	
Instead of examining the bug:
	Say "The level of consistency is [the level of consistency of the bug].";
	Now the level of consistency of the bug is the level of consistency of the bug plus 10.
	
Every turn:
	If the level of consistency of the bug is at most 100:
		increment the level of consistency of the bug.

Although disambiguation problems leading to runtime errors can occur if you also declare an object called consistency and give it a number property called level…

Best advice is as you said, to avoid ‘of’ altogether in naming things or to hyphenate the name.