Next: , Previous: , Up: Interpreting Error Messages   [Contents][Index]


4.4.6 Read Errors

The compiler also handles errors while reading the source. For example:

Error: Read error at 2:
 "(,/\foo)"
Error in function LISP::COMMA-MACRO.
Comma not inside a backquote.

The “at 2” refers to the character position in the source file at which the error was signaled, which is generally immediately after the erroneous text. The next line, “(,/\foo)”, is the line in the source that contains the error file position. The “/\” indicates the error position within that line (in this example, immediately after the offending comma.)

When in Hemlock (or any other EMACS-like editor), you can go to a character position with:

M-< C-u position C-f

Note that if the source is from a Hemlock buffer, then the position is relative to the start of the compiled region or defun, not the file or buffer start.

After printing a read error message, the compiler attempts to recover from the error by backing up to the start of the enclosing top-level form and reading again with *read-suppress* true. If the compiler can recover from the error, then it substitutes a call to cerror for the unreadable form and proceeds to compile the rest of the file normally.

If there is a read error when the file position is at the end of the file (i.e., an unexpected EOF error), then the error message looks like this:

Error: Read error in form starting at 14:
 "(defun test ()"
Error in function LISP::FLUSH-WHITESPACE.
EOF while reading #<Stream for file "/usr/me/test.lisp">

In this case, “starting at 14” indicates the character position at which the compiler started reading, i.e. the position before the start of the form that was missing the closing delimiter. The line "(defun test ()" is first line after the starting position that the compiler thinks might contain the unmatched open delimiter.


Next: Error Message Parameterization, Previous: Errors During Macroexpansion, Up: Interpreting Error Messages   [Contents][Index]