Small change to Inform 6 compiler: directives in functions

A heads-up: when I was looking through the I6 source code a while back, I discovered that this was permitted by the compiler:

[ FuncName;
  #Global globvar = 1;
  return globvar;

That is, sticking a global variable definition inside a function. The source included this comment:

   (Technically this permits *any* #-directive, which means you
   can define global variables or properties or what-have-you in
   the middle of an object. You can do that in the middle of an
   object, too. Don't. It's about as well-supported as Wile E.
   Coyote one beat before the plummet-lines kick in.) */

In the interest of protecting Our Friend the Coyote, I am updating the compiler to treat this as an error.

In future releases, only the following directives will be accepted inside a function or object definition:

  #ifv3 #ifv5 #ifdef #ifndef #iftrue #iffalse #ifnot #endif
  #message #origsource #trace

This shouldn’t affect any real I6 (or I7) source code. Unless you are doing a weird trick like #including function code from one file into the middle of another function. If you are, please let me know!


Aren’t there other #ifv? directives for each version of the Z-machine that the compiler is able to produce.

No, those are the only two that exist. If you want to do finer discrimination, you write something like

#Iftrue (#version_number == 6);

The names are misleading anyhow. #ifv5 really means #version_number > 3. If we ever add v1/v2 support, #ifv3 will mean #version_number <= 3.