Discussion:
[racket] how to get line numbers on syntax errors on load?
Thomas Lynch
2015-03-10 04:44:10 UTC
Permalink
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?
Thomas Lynch
2015-03-10 05:12:34 UTC
Permalink
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 <
Post by Thomas Lynch
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.
Welcome to Racket v5.2.1.
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?
Greg Hendershott
2015-03-10 21:19:25 UTC
Permalink
Post by Thomas Lynch
Is there a way to coerce racket to be more specific in its messages?
Although I don't know if it would do better with this particular error,
generally errortrace gives much better stack traces:

http://docs.racket-lang.org/errortrace/quick-instructions.html

It does so by instrumenting the code. Which means it will run more
slowly. Which I imagine is why it's not enabled by default.
____________________
Racket Users list:
http://lists.racket-lang.org/users
Thomas Lynch
2015-03-11 05:08:38 UTC
Permalink
Greg, the code fails to load due to the error, so trace doesn't get a
chance to participate.
Post by Greg Hendershott
Post by Thomas Lynch
Is there a way to coerce racket to be more specific in its messages?
Although I don't know if it would do better with this particular error,
http://docs.racket-lang.org/errortrace/quick-instructions.html
It does so by instrumenting the code. Which means it will run more
slowly. Which I imagine is why it's not enabled by default.
Matthew Flatt
2015-03-13 19:41:52 UTC
Permalink
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.
Post by Thomas Lynch
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 <
Post by Thomas Lynch
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.
Welcome to Racket v5.2.1.
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?
____________________
http://lists.racket-lang.org/users
____________________
Racket Users list:
http://lists.racket-lang.org/users

Loading...