Here’s some code that appears to be considered problematic by compilers 6.31 through 6.35:
Constant Story "Child of variable holding class";
Constant Headline "^an example^";
Include "Parser";
Include "VerbLib";
Include "Grammar";
Class Room
has light;
Class Battery(5)
with name 'battery',
capacity 50;
Room Start "Starting Point"
with description
"An uninteresting room.";
Verb 'squint'
* 'at' noun -> Squint;
! Trace assembly 4;
[ SquintSub prot cla ;
cla = Battery;
prot = child(cla); ! RTE triggered by this line
];
! Trace assembly off;
[ Initialise ;
location = Start;
print "The child of Battery is: ", (name) child(Battery), ".^";
];
This is what the issue arising looks like, an RTE that does not appear to have a valid cause:
The child of Battery is: Battery_1. ! <---- no problem when requesting child of class as constant
Child of variable holding class
an example
Release 1 / Serial number 210418 / Inform v6.34 Library 6/11 S
Starting Point
An uninteresting room.
>SQUINT AT ME
[** Programming error: tried to find the "child" of Battery **] ! <--- problem when requesting child of same class
Examination of the assembly trace shows that the RTE is being generated as part of what looks like hardcoded guards inserted by the compiler:
26 +0d150 [ SquintSub prot cla
27 +0d151 <*> store cla short_26
0d 02 1a
28 +0d154 <*> jg short_5 cla to L1 if TRUE <--- ensures not checking child of Class, Object, String or Routine
23 05 02 80 01
28 +0d159 jg cla long_12 to L1 if TRUE <--- PROBLEM LINE - unknown purpose
c3 8f 02 00 0c 80 01
28 +0d160 jin cla short_1 to L0 if FALSE
46 02 01 00 00
28 +0d165 .L1
28 +0d165 call_vn long_22 short_6 cla <--- equiv to RT__Err(6); "tried to find a child of..." (?)
f9 1b 00 16 06 02
28 +0d16b store TEMP2 short_2
0d fe 02
28 +0d16e jump L2
8c 00 02
28 +0d171 .L0
28 +0d171 store TEMP2 cla
2d fe 02
28 +0d174 .L2
28 +0d174 get_child TEMP2 -> prot (no branch)
a2 fe 01 42
29 +0d178 <*> rtrue
b0
The RTE does not appear if the code is compiled with strict
mode off.
Does anyone know what the intent of the line marked “PROBLEM LINE
” is? The instruction is equivalent to “jump to L1 if cla > 12
”, but the significance of 12
in this context isn’t clear.