[racket] how to get line numbers on syntax errors on load?

From: Matthew Flatt (mflatt at cs.utah.edu)
Date: Fri Mar 13 15:41:52 EDT 2015

Sometimes, source locations are missing because the relevant expression
or definition was macro-introduced. Syntax in macro templates currently
does not preserve its source location when compiled to ".zo" format.
That choice was intended to keep bytecode files smaller, but I expect
we'll revisit it in the near future.

The error below, however, is a "something bad happened" kind of error.
I think it's likely a problem with `enter!` and its underlying support
in v5.2.1. If I remember correctly, I fixed a bug or two since that
release related to `enter!` and "link: ..." errors. More generally, you
shouldn't get "link:" errors unless compiled code is mangled or
mismanaged.

At Tue, 10 Mar 2015 13:12:34 +0800, Thomas Lynch wrote:
> It is scary to run regression on over ten thousand lines of code and then
> racket spits out error messages but does not give source file location
> information, as above.   So if anyone has an answer for this I would like
> to hear it.
> 
> FYI,  in this particular case,  test-hook was defined lower in the
> basic-lib.rkt than its first invocation - though at top level of the
> module.  Not sure why this scenario fails here, now, but the test-hook
> definition was easily moved up.  The error messaged mentioned test-hook,
> but that was practically meaningless as every regression routine has one.
> ... It had nothing to do with macros or unicode as first thought.
> 
> 
> 
> On Tue, Mar 10, 2015 at 12:44 PM, Thomas Lynch <
> thomas.lynch at reasoningtechnology.com> wrote:
> 
> > When loading modules I sometimes get syntax errors - rightfully so.
> > However, the errors sometimes don't have line numbers, making them time
> > consuming to find.
> >
> > Here is one today:
> >
> > Welcome to Racket v5.2.1.
> > racket@> (enter! "ap.rkt")
> > link: reference (phase 0) to a variable in module "basic-lib.rkt" that is
> > uninitialized (phase level 0); reference appears in module: "realtime.rkt"
> > in: test-hook
> >
> >
> >
> > Which variable?  Which line in which file?
> >
> > This is old code that is not playing well within a new environment. There
> > are thousands of combinations possible against this information.   .. I
> > suspect this has to do with using unicode characters, specifically lambda,
> > within macros, if so it will not be long to find it.  However, in the worse
> > case I will have to start a binary search cutting out blocks of code, and
> > inserting stub routines .. but this is time consuming, and this sort of
> > vague message is not a one time occurrence.
> >
> > Is there a way to coerce racket to be more specific in its messages?
> >
> >
> ____________________
>   Racket Users list:
>   http://lists.racket-lang.org/users

Posted on the users mailing list.