Opened 11 years ago
Closed 9 years ago
#1083 closed defect (invalid)
cannot import procedure from one egg during macro expansion in another egg.
Reported by: | Alan Post | Owned by: | |
---|---|---|---|
Priority: | not urgent at all | Milestone: | someday |
Component: | compiler | Version: | 4.8.x |
Keywords: | Cc: | alanpost@… | |
Estimated difficulty: |
Description
I have two eggs, m0 and m1.
m0 defines a single procedure, f0.
m1 contains an ir-macro make-f1, which defines the procedure f1. It calls m0#f0 during macro expansion.
I get the following error during macro expansion, claiming f1 is undefined:
Error: during expansion of (make-f1 ...) - unbound variable: f0
I believe f0 is bound, and that this expansion should succeed. See attached files.
my csc version:
--(>:)-- csc -V
(c) 2008-2013, The Chicken Team
(c) 2000-2007, Felix L. Winkelmann
Version 4.8.0.5 (stability/4.8.0) (rev f60b2b6)
openbsd-unix-gnu-x86 [ manyargs dload ptables ]
compiled 2013-12-10 on celia.c0redump.org (OpenBSD)
Attachments (4)
Change History (8)
Changed 11 years ago by
comment:1 Changed 11 years ago by
Priority: | major → not urgent at all |
---|
evhan, on IRC, found the appropriate invocation:
(begin-for-syntax
(require-library m0))
(import-for-syntax m0)
Is this still a bug? Since there is a workaround, I'm dropping the priority.
comment:2 Changed 11 years ago by
Cc: | alanpost@… added |
---|
comment:3 Changed 11 years ago by
I think the important difference in the working paste is actually just having (import scheme)
before the begin-for-syntax
form. As long as that's true, any other permutation of the imports works:
(import-for-syntax scheme) (import-for-syntax chicken) (import scheme) (begin-for-syntax (use m0)) (import chicken) ;; ... whatever else ...
This is because the scheme
namespace is the one that provides begin-for-syntax
, so without it the begin-for-syntax
isn't expanded and m0
isn't loaded in m1
at expansion time (making f0
a run-of-the-mill unbound variable). I'd call this a gotcha rather than a bug, though maybe a warning for forms that are probably meant to be syntax like this (such as the {import,require,use}[-for-syntax]
family) would be helpful?
comment:4 Changed 9 years ago by
Resolution: | → invalid |
---|---|
Status: | new → closed |
Closing as invalid after looking into this again. The current behaviour is as expected, just a bit obscured by the macrology.
m0.scm