| Reporter's email: |
newton@mit.edu |
| Number: |
10814 |
| Category: |
all |
| Synopsis: |
Problem with 'include'd file macro-def, not in 4.1 appears in 4.2.2, 4.2.3.4, and 4.2.4 |
| Class: |
sw-bug |
| Responsible: |
nobody |
| Notify-List: |
|
| Severity: |
critical |
| Priority: |
medium |
| State: |
open |
| Confidential: |
no |
| Arrival-Date: |
Fri Mar 05 17:08:02 -0500 2010 |
| Closed-Date: |
|
| Last-Modified: |
Fri Mar 05 21:56:01 -0500 2010 |
| Originator: |
Ryan Newton |
| Organization: |
plt
|
| Submitter-Id: |
unknown |
| Release: |
4.2.4 |
| Environment: |
MacIntel / Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; en-US; rv:1.9.1.8) Gecko/20100202 Firefox/3.5.8
|
| Description: |
I have an R6RS codebase which runs under ikarus, chez, and plt. Recently, (plt >4.1) I started running into an odd compile problem.
I happen to have a library which has part of its guts split out into another file (and pulled back in via include). (I think it wasn't its own module because of recursive dependencies.)
I also happen to have redefined "include" because I needed it to be relative to a particular absolute path.
The combination of these things seems to result in a spurious "__ is undefined" error when the include-ee tries to access something defined in the include-er.
I've boiled the problem down to the attached three small files. Triggering the problem does seem to require a combination of factors. There are three files:
test.sls -- main module that does the "myinclude"
lib/test2.sls -- file that is "myinclude"d
lib/test3.sls -- file that defines "myinclude"
One thing you will see is that if myinclude is defined in test.sls, NOT in test3.sls, then the problem doesn't occur. (Likewise it doesn't occur when using the PLT builtin include directly.)
Another oddity is that changing the name of the variable that is "undefined" changes the error message. If you change it to "x" you will get "identifier used out of context in: x".
Good luck!
-Ryan
|
| File Attachments: |
|
| How-To-Repeat: |
Note, I also posted a tarball, which is easier than dissecting what's below:
http://people.csail.mit.edu/newton/temp/possible_include_bug.tgz
After copying the follow code listings to their corresponding files,
they should be runnable with:
export THEDIR=`pwd`
export PLTCOLLECTS=:$THEDIR
mzscheme -t test.sls
test.sls
================================================================================
#!r6rs
(library (test)
(export )
(import (rnrs (6))
;; Why does this not work, just expand?
;(for (lib test3) expand)
(for (lib test3) run expand)
(for (only (scheme base) getenv file) run expand)
(for (prefix (scheme include) plt:) run expand)
(for (rnrs eval (6)) run expand)
)
;; If I define my version of include here, it works!
;; If I pull the definition of myinclude from (lib test3), it fails!
#;
(define-syntax myinclude
(lambda (x)
(syntax-case x ()
[(_ fn)
(let ([regd (getenv "THEDIR")])
(let ((path (string-append regd "/" (syntax->datum #'fn))))
(display "Include resolved to: ") (display path) (newline)
#`(plt:include (file #,(datum->syntax #'_ path)))
))])))
;; Define something here and use it in the included file:
;; ------------------------------------------------------------
;; These get an unbound identifier error:
(define hatch 3)
;; This gets a different error (identifier used out of context):
;(define x 3)
;; Include the file:
;; ------------------------------------------------------------
;; A normal PLT include works, but my version doesn't:
;(plt:include "test2.sls")
(myinclude "lib/test2.sls")
)
lib/test2.sls
================================================================================
;(define y (match 3 [3 4]))
;(define y match)
(define y hatch)
;;
;(define y x)
(display "Included file..\n")
lib/test3.sls
================================================================================
#!r6rs
(library (test3)
(export myinclude)
(import
(rnrs (6))
(for (rnrs eval (6)) run expand)
(for (only (scheme base) getenv file) run expand)
(prefix (only (scheme include) include) plt:)
)
(define-syntax myinclude
(lambda (x)
(syntax-case x ()
[(_ fn)
(let ([regd (getenv "THEDIR")])
(let ((path (string-append regd "/" (syntax->datum #'fn))))
(display "Include resolved to: ") (display path) (newline)
#`(plt:include (file #,(datum->syntax #'_ path)))
))])))
)
|
| Fix: |
|
| Release-Note: |
|
| Unformatted: |
|