Chapter 14: Error Messages and Diagnostics
The compiler provides a rich set of diagnostic messages to help programmers identify and fix problems in their source code. This chapter catalogs the three categories of compile-time diagnostic messages - fatal errors, errors, and warnings - and summarizes the runtime and debugging facilities that §34 (Debugging and Testing) covers in full.
14.1 Overview
The compiler reports three categories of diagnostic messages during compilation:
| Category | Severity | Compilation continues? | Output produced? |
|---|---|---|---|
| Fatal error | Highest | No - immediate halt | No |
| Error | Medium | Yes - to find more | No |
| Warning | Lowest | Yes | Yes |
Fatal errors represent unrecoverable conditions: the compiler cannot proceed and terminates immediately with a non-zero exit code.
Errors indicate definite problems in the source code - syntax violations, undefined symbols, type mismatches, and so on. When an error is encountered, the compiler attempts to recover and continue parsing so that it can report as many errors as possible in a single run. However, no output file is produced.
Warnings flag potential problems that may or may not be actual bugs. The
source code is technically valid, and the compiler produces an output file, but
you should review the flagged constructs. Warnings can be suppressed with the
-w switch.
All three categories include the source file name and line number (when available) so that you can locate the problem quickly.
14.2 Fatal Errors
Fatal errors represent conditions from which the compiler cannot recover. When one occurs, compilation stops immediately, and no story file is written.
14.2.1 Format
Fatal errors are printed in the form:
Fatal error: description
The compiler then exits with a non-zero exit code, which build scripts and Makefiles can test.
14.2.2 Common Fatal Errors
| Message | Cause |
|---|---|
Couldn't open source file "filename" |
The named source file does not exist or is not readable. |
Run out of memory allocating ... bytes for ... |
The compiler has exhausted the host system's available memory while growing an internal table. The fix is to make more system memory available or reduce the program's size. |
Too many errors: giving up |
The error count has reached the hard-coded maximum of 100. This prevents runaway error cascading. |
I/O failure: couldn't write to story file |
The compiler cannot write the story file - typically a permissions or disk-space problem. |
14.2.3 Example
Fatal error: Couldn't open source file "story.inf"
This typically means the filename is misspelled, the file is in a different
directory, or the include path (set with +include_path=...) does not point to
the right location. See §11.3 for path configuration.
14.3 Errors
Errors indicate definite problems in the source code. The compiler reports the error but attempts to recover and continue parsing, allowing multiple errors to be found in a single compilation run.
14.3.1 Format
The default error format is:
"filename", line N: Error: description
The format can be changed with the -E switch (see §12.1.3).
14.3.2 Error Recovery
After encountering an error, the compiler skips tokens until it reaches a point where parsing can safely resume - typically the next semicolon, closing brace, or directive keyword. This recovery is imperfect: a single real mistake (such as a missing semicolon) can sometimes trigger a cascade of spurious follow-on errors. As a rule of thumb, fix the first reported error and recompile before tackling later ones.
If the total number of errors reaches the hard-coded maximum of 100, the
compiler issues the fatal error Too many errors: giving up and halts to
prevent unbounded output.
14.3.3 Common Errors
Syntax errors
"game.inf", line 42: Error: Expected ';' but found x
A semicolon is missing at the end of a statement or directive. This is by far the most common error.
"game.inf", line 18: Error: Expected directive but found Obiect
A top-level directive is misspelled - here Object was typed as Obiect.
Undefined symbols
"game.inf", line 57: Error: No such constant as "lantern"
The identifier lantern has not been declared. Check spelling and ensure that
the file defining the symbol is Included before the point of use.
Exceeding VM limits
"game.inf", line 200: Error: All 48 attributes already declared
The Z-machine allows a maximum of 48 attributes in v4 and later (32 in v3)
[Z-machine], while Glulx raises this to a configurable higher limit [Glulx]. If
you hit this limit on the Z-machine, consider combining related attributes or
switching to Glulx with the -G switch.
"game.inf", line 310: Error: All 61 properties already declared
Similarly, the Z-machine limits user-declarable common properties to 61 in v4 and later (29 in v3) [Z-machine]. Glulx permits many more [Glulx].
Type checking
The compiler performs additional type checking during ordinary compilation, independent of strict mode. A type mismatch is reported via a warning of the form:
"game.inf", line 85: Warning: In <context>, expected <type> but found <type> "name"
This indicates that a value is being used in a context that expects a different type - for example, using a string where a routine address is required.
Other common errors
| Message | Explanation |
|---|---|
Expected <thing> but found <thing> |
The parser expected a specific token (keyword, bracket, operator) that was not found. |
Property given twice in the same declaration: "name" |
An object definition provides the same property more than once. |
Too many local variables for a routine; max is N |
The Z-machine allows at most 15 locals per routine [Z-machine]; Glulx allows more [Glulx]. |
"name" is a name already in use ... |
A symbol with this name already exists. |
14.4 Warnings
Warnings indicate potential problems that do not prevent compilation. The output file is still produced, but you should review the flagged code.
14.4.1 Format
"filename", line N: Warning: description
14.4.2 Suppressing Warnings
All warnings can be suppressed with the -w switch:
inform -w game.inf
This is useful when compiling legacy code that triggers many harmless warnings, but in general, it is better to fix the underlying causes.
14.4.3 Common Warnings
Unreachable code
"game.inf", line 90: Warning: This statement can never be reached
Code appears after a return, rtrue, rfalse, jump, or quit statement,
where it can never be executed:
[ MyRoutine;
return 42;
print "This line is never reached.^"; ! Warning here
];
Unused variables
"game.inf", line 12: Warning: Local variable "temp" declared but not used
A local variable is declared but never referenced in the routine body. Either remove the declaration or use the variable:
[ MyRoutine temp;
! 'temp' is declared, but the routine never mentions it
print "Hello!^";
];
Obsolete usage
"game.inf", line 5: Warning: Obsolete usage: description
The source uses a deprecated syntax that may be removed in future compiler versions. The warning message describes the preferred replacement.
Value overflow
"game.inf", line 77: Warning: Entry in '->', 'string' or 'buffer' array not in range 0 to 255
A byte array (->) or a string/buffer array - where each entry is a single
byte - is declared with an initializer entry larger than 255. (The warning
applies to array-declaration initializers; a run-time store such as
counts->0 = 300 is silently truncated to a byte and is not diagnosed.)
Array counts -> 300 200 100; ! Warning: entry 300 exceeds 255
Other common warnings
| Message | Explanation |
|---|---|
'=' used as condition: '==' intended? |
An = appears where == was probably intended inside an if test. |
Logical expression has no side-effects |
An expression statement evaluates a logical operator whose result is discarded. |
Using '->' to access a --> or table array |
A byte-array operator is being used on a word-array, or vice versa. |
Bare property name found. "self.prop" intended? |
A property name appears in an expression without an object qualifier. |
14.5 Runtime and Debugging Diagnostics
The diagnostics above are all produced at compile time. The compiler and standard library additionally provide facilities that operate at runtime or assist debugging; these are documented in §34 (Debugging and Testing) and summarised here.
Runtime error checking (strict mode). When strict mode is active - the -S
switch, on by default (see §12.1.3) - the compiler inserts runtime checks for
array-bounds violations, invalid object references, division by zero, illegal
object-tree operations, and stack underflow. A failed check calls the veneer
routine RT__Err, which prints a message of the form:
[** Programming error: description **]
The game usually continues afterward, though its state may be inconsistent. See
§34.1.2 for what each check covers, §34.5.5 for the message format and worked
examples, and Appendix F §F.6.2 for the complete list of numeric RT__Err error
codes and their messages.
The Infix debugger (-X) compiles an interactive source-level debugger into
the story file, letting you inspect and modify objects, properties, variables,
and routines at runtime. See §34.2.
The debug file (-k, written to gameinfo.dbg) records the mapping between
compiled addresses and source locations so that source-level debuggers can step
through the code. See §34.4.
The Trace directive and the $! command-line trace options print the
compiler's internal processing - assembly, expression trees, tokens, and the
dictionary/object/symbol/verb tables - during compilation. See §34.6.1-§34.6.2
(and §12.6 for the trace-option reference).
14.6 Best Practices
-
Fix errors from the top. The first error is the most reliable; later errors may be cascading artifacts. Fix the first error and recompile before investigating subsequent messages.
-
Don't suppress warnings carelessly. The
-wswitch hides all warnings. Instead, fix the underlying code. Unused variables and unreachable code often indicate logic errors. -
Use strict mode during development. The
-Sswitch (on by default) catches many bugs that would otherwise manifest as bizarre in-game behavior. Only turn it off for final release builds after thorough testing. -
Use the debug file for complex projects. The
-kswitch produces a debug information file that source-level debuggers can use to step through compiled code. -
Set
-E1for IDE integration. If your editor can parse compiler output and jump to error locations, the Microsoft-format-E1option provides the widest compatibility. -
Understand which limits are real. Inform 6 no longer has adjustable
$MAX_*table-size settings - internal tables grow dynamically, and those old settings were withdrawn (see §12.4.8 and §15.6). A "too many" or "exceeded limit" error therefore signals a genuine architectural limit of the target virtual machine (for example, the Z-machine's caps on objects, attributes, or properties) rather than a tunable buffer. Address it by reducing usage or, for the Z-machine caps, by switching to Glulx (next point). -
Consider Glulx for large projects. Many Z-machine limits on attributes, properties, objects, and code size are dramatically higher or absent in Glulx [Glulx]. Switching targets with
-Gcan eliminate entire categories of limit errors.