Inform - Support - Patches

About Patches  


DM4 Errata  

Issue C63021     [previous patch]

In a 'before' property, "print," crashes the compiler
Submitted by: milkshake     Appeared in: Compiler 6.30 or before     Fixed in: -

The compiler crashes hard when compiling this file, and produces no complaint about the syntax error present in the before property of the "thing" object. It's not just the print statement and the comma causing the problem, as it doesn't happen if you use that construction inside a description property.

  Constant Story "Test story";
  Constant Headline "^A simple Inform test^";

  Include "Parser";
  Include "VerbLib";
  Include "Grammar";

  [ Initialise; location = void; ];

  Object  void "Void"
    with  description "You stand in a featureless void.",
    has   light;

  Object  -> "thing"
    with  description "A miscellaneous thing.",
          name 'thing',
          before [;
              print, "It smells like every other miscellaneous thing you've ever smelled.";
Solution (by Cedric Knight)

The compiler sees the comma and interprets the line as an action switch case. The string, which is longer than an identifier is expected to be, is then passed to action_of_name(), which is where the crash actually happens. Adding a few lines around the function call in parse_switch_spec safeguards against this:

  if (token_type == SYMBOL_TT || token_type >= STATEMENT_TT)
      spec_stack[spec_sp] = action_of_name(token_text);
      { spec_stack[spec_sp].value = -1; /* signal as invalid action */
        warning("Extraneous comma or 'to'? This looks like a switch() case.");

Last updated 17 April 2013. This site is no longer supported; information may be out of date.
Maintained as a historical archive by the Interactive Fiction Technology Foundation. Copyright 1993-2018 IFTF, CC-BY-SA unless otherwise noted.
This page was originally managed by Roger Firth.