I ran into an issue that seems like it should have come up before.
"Schrodinger's Cat"
A cat is a kind of animal.
Place is a room.
When play begins:
if the player is a cat:
say "Surprisingly, you are a cat!";
otherwise:
say "You don't seem to be a cat at first glance.";
let napsack be a cat; [unexpected behavior occurs here]
say "[The napsack] [are] apparently a cat, though."
This yields:
You don't seem to be a cat at first glance.
You are apparently a cat, though.
The generated I6 contains:
! ----------------------------------------------------------------------------------------------------
! Rules in rulebook: When play begins (B4_when_play_begins)
! ----------------------------------------------------------------------------------------------------
! Rule 1/1 ! When play begins:
! ----------------------------------------------------------------------------------------------------
! No specific request
! When play begins:
[ R_799
tmp_0 ! Let/loop value, e.g., 'napsack': thing
;
if (debug_rules) DB_Rule(R_799, 799);
! [2: if the player is a cat]
if (((player ofclass K16_cat)))
{! [3: say ~Surprisingly, you are a cat!~]
say__p=1;! [4: ~Surprisingly, you are a cat!~]
ParaContent(); print "Surprisingly, you are a cat!"; new_line; .L_Say1; .L_SayX1;} else {
! [5: say ~You don't seem to be a cat at first glance.~]
say__p=1;! [6: ~You don't seem to be a cat at first glance.~]
ParaContent(); print "You don't seem to be a cat at first glance."; new_line; .L_Say2; .L_SayX2;}
! [7: let napsack be a cat]
tmp_0 = selfobj;
! [8: say ~[The napsack] [are] apparently a cat, though.~]
say__p=1;! [9: the napsack]
ParaContent(); print (The) tmp_0;! [10: ~ ~]
ParaContent(); print " ";! [11: are]
ConjugateVerb_0(CV_POS, PNToVP(), story_tense); say__p=1; ! [12: ~ apparently a cat, though.~]
ParaContent(); print " apparently a cat, though."; new_line; .L_Say3; .L_SayX3;rfalse;
];
! ----------------------------------------------------------------------------------------------------
The temporary value for napsack
should be being set to an arbitrary cat. There is no actual cat defined in the scenario, so presumably it is assigning selfobj
as a placeholder. However, the same I6 code (and same unexpected behavior) results even when cats have been defined, as can be seen by adding to the example above:
Morris is a cat in Place. Felix is a cat in Place.
Note that the unexpected behavior is avoided by replacing the line:
let napsack be a cat; [unexpected behavior occurs here]
with:
let napsack be the default value of cat; [works as expected]
With that definition, if no cat is defined, the following problem message is generated:
Problem. I am unable to find a cat to use here, because the world does not contain a cat.
See the manual: 4.12 > 4.12. Values that vary
Is the compiler’s behavior proper for the first (let napsack be a cat;
) version?
Note that the above example is contrived to illustrate the point. In the original context in which I encountered this, a run-time error was being generated:
*** Run-time problem P47 (at paragraph 63 in the source text): Phrase applied to an incompatible kind of value.
with the same root cause of a temporary cat variable being assigned the value of selfobj
.