Opened 14 years ago

Closed 14 years ago

Last modified 14 years ago

#268 closed defect (fixed)

Chicken 4.5.0 has a strange issue with out-of-module imports

Reported by: sjamaan Owned by: sjamaan
Priority: critical Milestone:
Component: extensions Version: 4.5.x
Keywords: macros, s48-modules, modules Cc:
Estimated difficulty:

Description

Simply put, in chicken 4.4.0, chicken-install prometheus succeeds. In chicken 4.5.0 it doesn't:

Warning: reference to possibly unbound identifier: include-relative
Error: module unresolved: _hermes

For some reason the (require-extension s48-modules) is not working correctly. Commenting out a couple of the earlier module declaration forms in prometheus.scm cause it to understand the include-relative.

It's a really weird issue and I'm still not sure what the exact cause is, but I decided to create a ticket so we can keep track of this. I will try to do some more investigation, but perhaps you already have an idea what could be the cause of this, Felix?

Change History (5)

comment:1 Changed 14 years ago by felix winkelmann

Status: newaccepted

comment:2 Changed 14 years ago by felix winkelmann

Component: compilerextensions
Keywords: s48-modules added
Milestone: 4.6.0
Version: 4.5.04.5.x

comment:3 Changed 14 years ago by felix winkelmann

Owner: changed from felix winkelmann to sjamaan
Status: acceptedassigned

Below is a patch for s48-modules that seems to help. That extension definitely was incorrect for not importing include-relative, since it is used for the files clause. Why it seems to work with modules removed I can't say right now. Since modules are syntax-stripped anyway, all the renaming doesn't make much of a difference.

I also fixed a problem for using include-relative outside of a loaded file.
Please try the patch and tag a new version, if it works for you.

Index: s48-modules.scm
===================================================================
--- s48-modules.scm     (revision 18383)
+++ s48-modules.scm     (working copy)
@@ -26,7 +26,11 @@
   (define-syntax include-relative
     (lambda (x r c)
       (let* ((old-file (s48-modules:get-current-file))
-             (file (make-pathname (pathname-directory old-file) (cadr x))))
+             (file (make-pathname
+                   (if old-file
+                       (pathname-directory old-file)
+                       ".")
+                   (cadr x))))
         `(,(r 'begin)
           (,(r 's48-modules:set-current-file!) ,file)
           (,(r 'include) ,file)
@@ -176,7 +180,7 @@
                             "invalid structure clause"
                             clause))))))
        (let ((names (map (lambda (n) (##sys#strip-syntax (car n))) (cadr x))))
-         (when (and (memq #:compiling ##sys#features)
+         (when (and (feature? #:compiling)
                     (any (lambda (n) (assq n ##compiler#import-libraries))
                          names))
            (set! ##compiler#import-libraries
@@ -185,7 +189,9 @@
               (string-append (symbol->string iname1) ".import.scm")
               ##compiler#import-libraries) ) ) )
        `(,%begin
-         (,%module ,iname1 * ,@(process-body (cddr x) #f))
+         (,%module ,iname1 *
+                   (import (only s48-modules include-relative))
+                   ,@(process-body (cddr x) #f))
          ,@(map process1 (cadr x))))))

 )

comment:4 Changed 14 years ago by sjamaan

Resolution: fixed
Status: assignedclosed

Thanks Felix, this patch works great. How silly of me, I thought the bug was caused by the toplevel prometheus.scm wrapper file.

comment:5 in reply to:  4 Changed 14 years ago by felix winkelmann

Replying to sjamaan:

Thanks Felix, this patch works great. How silly of me, I thought the bug was caused by the toplevel prometheus.scm wrapper file.

Well, the error was somewhat obscure. BTW - it may be the case that include-relative also has to be imported for syntax, in case the files clause also occurs inside a for-syntax form. I'm not completely sure about this, though.

Note: See TracTickets for help on using tickets.