Using #IfDef and #EndIf in this way creates a compilation error (maybe it makes sense?):
Constant XXX;
[ Test w;
w = 1;
if (w == 1)
print "1";
else if (w == 2)
print "2";
#IfDef XXX;
else if (w == 3)
print "3";
#EndIf;
else
print "*";
];
[ main; test(); ];
Inform 6.35 (in development)
line 9: Error: 'else' without matching 'if'
> else if
line 9: Error: Expected ';' but found if
> else if
line 12: Error: 'else' without matching 'if'
> print
line 12: Error: Expected ';' but found print
> print
Compiled with 4 errors (no output)
Informâs âpreprocessorâ actually isnât â thereâs no separate compilation pass, theyâre just special statements that tell the compiler to use or forget the statements within, but still part of the normal compilation pass, and those within still must be complete and syntactically valid statements â which half of an else block is not.
(This is why #Ifdef can report whether functions and other symbols have been defined or not, which isnât something that would be known yet to a C-like preprocessor.)
To accomplish that sort of if-chain, youâd need to remove the else and add return statements so that it doesnât fall through to the next case. Or some other change that ends up with complete statements in each block.
Yeah â this can reasonably be seen as a bug. As that link notes, it should be fixable, but it will require some careful fiddling and then a whole lot of testing.