Summary

import-for-syntax doesn’t seem to work right when the imported module is in the same file

Metadata

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.