Summary
import-for-syntax doesn’t seem to work right when the imported module is in the same file
Metadata
- Id: 0ae8cd5f13c99ae60c1e4b75179729444e58b5f4
- Trac id: 1341
- Type: defect
- Reporter: kooda
- Owner:
- Cc:
- Status: closed
- Component: compiler
- Estimated difficulty: hard
- Resolution: wontfix
- Priority: major
- Milestone: 5.0
- Version: 4.11.0
- Changetime: 2017-01-24 14:49:46 UTC
- Created: 2017-01-24 12:54:09 UTC
- Keywords:
Description
This snippet works in csi but doesn’t when compiled:
(module truc (coucou)
(import scheme)
(define (coucou)
`(display "coucou\n")))
(module bidule (blah)
(import scheme chicken)
(import-for-syntax truc)
(define-syntax blah
(er-macro-transformer
(lambda (f r c)
(coucou)))))
(import bidule)
(blah)
It gives different error messages whether on CHICKEN 4 or CHICKEN 5:
CHICKEN 4 error:
Error: during expansion of (blah ...) - unbound variable: truc#coucou
Call history:
<syntax> (##core#begin (blah))
<syntax> (blah)
<eval> (coucou) <--
CHICKEN 5 error:
Error: cannot load extension: truc
Call history:
<syntax> (##core#undefined)
<syntax> (##core#require chicken chicken#)
<syntax> (##core#begin (##core#require-for-syntax chicken-syntax) (##core#require library))
<syntax> (##core#require-for-syntax chicken-syntax)
<syntax> (##core#require library)
<syntax> (##core#undefined)
<syntax> (import-for-syntax truc)
<syntax> (##core#elaborationtimeonly (##core#begin (import26 truc)))
<syntax> (##core#begin (import26 truc))
<syntax> (import26 truc)
<syntax> (##core#begin (##core#require truc truc#))
<syntax> (##core#require truc truc#)
<syntax> (##sys#load-extension (##core#quote truc) (##core#quote (truc#)))
<syntax> (##core#quote truc)
<syntax> (##core#quote (truc#))
<eval> (##sys#load-extension (##core#quote truc) (##core#quote (truc#))) <--
Changes and comments
[2017-01-24 14:49:46 UTC] kooda changed status from new to closed
[2017-01-24 14:49:46 UTC] kooda set resolution to wontfix
[2017-01-24 14:49:46 UTC] kooda wrote:
The compiler has to load the module used for syntax, that’s why it doesn’t work.
Enclosing the module into begin-for-syntax does the right thing.