I have a couple of files written in Chez Scheme, each about a thousand lines. When I try to load a file into the REPL:
> (load "filexxx.scm")
...
Exception: variable A is not bound
Type (debug) to enter the debugger.
How can I figure out which line from which file triggered this exception?
I mainly use Racket, where DrRacket would have pointed me to the line causing the exception. Is there a similar way to find where the undefined variable A is being used in Chez?
Obtaining source location for exceptions can be frustrating in Chez Scheme. In this particular case, it may work to define identifier syntax for
Athat reports the location.filexxx.scm
This indicates
Ais referenced at 0-based character offset 26 infilexxx.scm.Alternatively, you can use the debugger to gain context, though maybe not a line or character number.
If
Aoccurs in a variable definition ...filexxx.scm
... you'll likely find yourself in the compiler, as seen below. (Enter
ito inspect the continuation, thensfto list frames.)Use
dandsto walk and inspect the stack frames until you see something familiar.Here, we see
my-var, which provides a clue.On the other hand, if
Aoccurs somewhere other than a variable definition ...filexxx.scm
... you'll likely find yourself at the site of the reference.
Here, we see
my-procedure, another clue. And showing the frame withsreveals the expression within whichAoccurs.