Opened 8 years ago

Closed 8 years ago

#1341 closed defect (wontfix)

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

Reported by: Kooda Owned by:
Priority: major Milestone: 5.0
Component: compiler Version: 4.11.0
Keywords: Cc:
Estimated difficulty: hard

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#)))     <--

Change History (1)

comment:1 Changed 8 years ago by Kooda

Resolution: wontfix
Status: newclosed

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.

Note: See TracTickets for help on using tickets.