Summary
Report the top-level binding that an error occurs in
Metadata
- Id: 56251046330e60c0f5f9f6305012ccd657f6ce34
- Trac id: 381
- Type: enhancement
- Reporter: alaric
- Owner: felix
- Cc:
- Status: closed
- Component: expander
- Estimated difficulty:
- Resolution: fixed
- Priority: major
- Milestone: 4.9.0
- Version: 4.5.0
- Changetime: 2012-09-24 21:47:48 UTC
- Created: 2010-09-12 19:20:55 UTC
- Keywords:
Description
One bane of my life is errors like this:
Warning: reference to possibly unbound identifier: archive Error: module unresolved: ugarit-core
...when just about *every* procedure in ugarit-core has an 'archive' parameter. I eventually traced down the problem with a binary chop by putting deliberate references to unbound identifiers in and looking at the order of the unbound identifiers reported.
I'm not sure if line-number information persists into the expander, but I think that it should be possible to work out the name of the top-level binding (DEFINE, DEFINE-SYNTAX, or whatever) it's inside. I'm guessing that the unbound references are detected after any macros that expand *into* top-level bindings are expanded, so this mechanism would still produce useful results in such situations.
Inside the expander, ##sys#register-undefined registers undefined symbols, but it only seems to be called by ##sys#alias-global-hook which is in turn called only by ##sys#strip-syntax, and I'm not sufficiently versed in Chicken internals to work out what's what above that, as it's called in lots of places.
I see that it's called directly inside many of the core macro definitions inside expander.scm; would it therefore suffice to define a parameter for the "current top-level definition" and set it to the defined name in the macro expanders for DEFINE, DEFINE-SYNTAX, and any others, and if that parameter is not at its default value of #f, report it in errors (and make the unbound identifier list for the module be a list of pairs, mapping unbound identifiers to the top-level definitions they're in?
Would that work, or is strip-syntax called in other dynamic contexts?
Changes and comments
[2010-09-13 09:46:33 UTC] felix changed status from new to assigned
[2010-09-13 09:46:33 UTC] felix set owner to felix
[2010-10-08 09:11:12 UTC] felix changed status from assigned to closed
[2010-10-08 09:11:12 UTC] felix set resolution to fixed
[2010-10-08 09:11:12 UTC] felix wrote:
Should be better in 4.6.2. This required passing along the name of the current "containing" lambda expression inside the code-walker for the compiler and wasn't completely trivial. Apologies for the delay.
[2011-06-01 09:00:41 UTC] felix changed milestone from 4.7.0 to 4.8.0
[2011-06-01 09:00:41 UTC] felix wrote:
Milestone 4.7.0 deleted
[2012-09-24 21:47:48 UTC] felix changed milestone from 4.8.0 to 4.9.0
[2012-09-24 21:47:48 UTC] felix wrote:
Milestone 4.8.0 deleted