DavidKinder / Inform6

The latest version of the Inform 6 compiler, used for generating interactive fiction games.
http://inform-fiction.org/
Other
204 stars 34 forks source link

Allow forward jumps to "unreachable" labels #197

Closed erkyrath closed 2 years ago

erkyrath commented 2 years ago

We now permit this pattern:

if (condition) jump MiddleLabel;
if (0) {
    while (condition) {
      ...
    .MiddleLabel;
      ...
    }
}

This is similar to the example in the release notes, except that the jump is before MiddleLabel. So when we reach MiddleLabel, we know it's in use.

This pattern, weird as it looks, is regularly used by Inform 7 adjective code. Inciting example:

To tally (D - a description of things): say "Tallied."

When play begins:
        tally all open doors.
erkyrath commented 2 years ago

This doesn't change behavior for any code that compiled under 6.40. It just compiles more code.

Test case: https://github.com/erkyrath/Inform6-Testing/blob/forward-jumps/src/branchprune-fwd.inf