#1494 closed defect (invalid)

Indirect exports with (export (foo bar)) style are not working

Reported by: megane Owned by:
Priority: major Milestone: 5.1
Component: compiler Version: 5.0.0
Keywords: modules Cc:
Estimated difficulty: hard

Description

(module
 m
 () ;; ((foo bar)) works here
 (import scheme)
 (cond-expand
  (chicken-5 (import (chicken base) (chicken module)))
  (else (import chicken)))

 (define (bar) 1)

 (export (foo bar))

 (define-syntax foo
   (ir-macro-transformer
    (lambda (e inj cmp)
      '(bar)))))

(import m)

(print (foo))

;; $ csi -qbn macroexport.scm
;; 
;; Warning: indirect export of unknown binding in module `m': bar
;; 
;; Error: unbound variable: bar
;; 
;; 	Call history:
;; 
;; 	<syntax>	  (lambda (e inj cmp) (quote (bar)))
;; 	<syntax>	  (##core#lambda (e inj cmp) (quote (bar)))
;; 	<syntax>	  (##core#begin (##core#quote (bar)))
;; 	<syntax>	  (##core#quote (bar))
;; 	<eval>	  (ir-macro-transformer (lambda (e inj cmp) (quote (bar))))
;; 	<syntax>	  (##core#undefined)
;; 	<eval>	  (##sys#load-library (##core#quote library))
;; 	<eval>	  (##sys#load-library (##core#quote library))
;; 	<syntax>	  (import m)
;; 	<syntax>	  (##core#begin (##core#undefined))
;; 	<syntax>	  (##core#undefined)
;; 	<syntax>	  (print (foo))
;; 	<syntax>	  (foo)
;; 	<syntax>	  (bar300)
;; 	<eval>	  (print (foo))
;; 	<eval>	  (bar300)	<--

Change History (2)

comment:1 Changed 14 months ago by Kooda

The documentation for the (export) form explicitly states that “An export must precede its first occurrence (either use or definition).”

It works fine in this case, just move your export declaration above bar’s definition.

comment:2 Changed 14 months ago by megane

Resolution: invalid
Status: newclosed

You are totally right. I'm not thinking..

Note: See TracTickets for help on using tickets.