Summary

Reexport behaving inconsistently

Metadata

Description

OK, so

(module (c)
(frobnicate)
(import scheme (chicken syntax))
(define-syntax frobnicate
  (syntax-rules ()
    ((frobnicate throwaway lis)
     (reverse lis)))))

(module (a)
()
(import c
        (rename scheme (reverse reverse-og))
        (rename (chicken base) (identity reverse))
        (chicken module))
(reexport c))

(import a scheme (chicken base))
(print (frobnicate 'a '(b c d e)))

prints out

(e d c b)

if it's all in the same file.

But if c separately is made into an egg and compiled, and then a separately is made into an egg and compiled, and the at the REPL you eval the last two lines, it prints out

(b c d e)

Changes and comments

[2021-05-26 13:05:49 UTC] sjamaan changed milestone from someday to 5.3

[2021-05-26 13:05:49 UTC] sjamaan wrote:

Need to investigate if we can fix this for 5.3

[2021-07-14 08:32:31 UTC] sjamaan wrote:

I think the problem is in ##sys#register-compiled-modules where it merges the syntax envs. I think this should not be done for macros that have been reexported - those should keep their original syntactic environment, unmodified.

Also, the syntactic envs from those macros should not be thrown into the module's total environment itself, I think. But that requires some more testing and experimentation. But it seems we already have quite a few tests for reexports, so maybe tweaking the code will trigger errors from which we can glean the correct behaviour.

[2021-07-14 11:27:40 UTC] sjamaan wrote:

hm, found another bug: if you re-export syntax that uses a module-local variable exported along with it, it cannot be looked up.

So instead of using `reverse` in `frobnicate`, you use `my-reverse`, it will break if accessed through the `a` module. It does work if accessed through the `c` module. The weird thing is that it will correctly rename the module, so I think the dependency simply isn't loaded.

[2021-07-14 11:28:10 UTC] sjamaan wrote:

Yeah, if you `require-library c` it works (so even if accessed through a).

[2021-07-14 11:53:27 UTC] sjamaan wrote:

hm, ok so if you import it first and then reexport it shouldn't have that problem. I don't know if that's a feature or a bug, but I guess it's unrelated to this ticket....

[2021-07-14 17:27:02 UTC] Idiomdrottning wrote:

The "except" import specifier doesn't seem to work properly with this patch. I'm working on, but haven't finished, making a minvia.

[2021-07-16 13:01:58 UTC] Idiomdrottning wrote:

See #1771.

[2021-07-31 06:06:57 UTC] evhan wrote:

Fixed by 3fd42518.

[2021-07-31 06:06:57 UTC] evhan changed status from new to closed

[2021-07-31 06:06:57 UTC] evhan set resolution to fixed