Opened 5 months ago

Closed 3 months ago

#1757 closed defect (fixed)

Reexport behaving inconsistently

Reported by: Idiomdrottning Owned by:
Priority: major Milestone: 5.3
Component: unknown Version: 5.2.0
Keywords: Cc:
Estimated difficulty:

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)

Change History (8)

comment:1 Changed 5 months ago by sjamaan

Milestone: someday5.3

Need to investigate if we can fix this for 5.3

comment:2 Changed 3 months ago by sjamaan

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.

comment:3 Changed 3 months ago by sjamaan

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.

comment:4 Changed 3 months ago by sjamaan

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

comment:5 Changed 3 months ago by sjamaan

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....

comment:6 Changed 3 months ago by Idiomdrottning

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

comment:7 Changed 3 months ago by Idiomdrottning

See #1771.

comment:8 Changed 3 months ago by evhan

Resolution: fixed
Status: newclosed

Fixed by 3fd42518.

Note: See TracTickets for help on using tickets.