Opened 3 months ago

Closed 2 months ago

#1771 closed defect (fixed)

Except specificier in imports

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

Description (last modified by sjamaan)

Note: this is with the patch for #1757 applied, for the future 5.3.0.

Here is the issue. If this is an egg,

cakes.scm:

(module cakes ()
(import scheme (chicken module) match-generics)
(reexport

(rename scheme (define define-og))
(rename match-generics (define-dx define))))

cakes.egg

((synopsis "A min via for import except")

(components (extension cakes)))

And here is a file that uses that egg:

(import (except cakes define))
(define (lamp x) 19)
(define (lamp x y) 21)
(+ (lamp 13 41)

(lamp 12))

The expected behavior is for this to bork or crash.

Instead it evals to 40, as if we had imported

(import (only cakes define))

Change History (10)

comment:1 Changed 3 months ago by sjamaan

define is a part of the default environment, so it's always there. You can import another definition which will override it, but you can't do it without.

If you put the file using the egg inside a module, it should work as expected.

comment:2 Changed 3 months ago by sjamaan

Description: modified (diff)
Milestone: someday5.3

comment:3 Changed 3 months ago by sjamaan

Slightly simplified:

;;; my-define.scm
(module my-define (define)
  (import (only scheme define-syntax syntax-rules) (only (chicken base) error))
  (define-syntax define
    (syntax-rules ()
      ((_ a b)
       (error "wrong define!")))))
;; reexported-my-define.scm
(module reexported-my-define ()
  (import (only my-define define) (chicken module))
  (reexport (only my-define define)))
;; at REPL
#;1> (import (except reexported-my-define define))
; loading ./reexported-my-define.import.scm ...
; loading ./my-define.import.scm ...

Note: re-importing already imported syntax: define
; loading ./reexported-my-define.so ...
; loading ./my-define.so ...
#;2> (define a 1)

Error: wrong define!
Last edited 3 months ago by sjamaan (previous) (diff)

comment:4 Changed 3 months ago by sjamaan

Note, this only goes wrong for macros:

;; my-display.scm
(module my-display (display)
  (import (only scheme define) (only (chicken base) error))
  (define (display x)
    (error "Wrong display")))
(module reexported-my-display ()
  (import (only my-display display) (chicken module))
  (reexport (only my-display display)))
;; at REPL
#;1> (import (except my-display display))
; loading ./my-display.import.scm ...
; loading ./my-display.so ...
#;2> (display "hi\n")
hi

comment:5 Changed 3 months ago by evhan

I can't reproduce this on master, with or without the patch for #1757. What am I missing?

comment:6 Changed 3 months ago by evhan

Resolution: fixed
Status: newclosed

Found it.

Git bisect has turned up that this was fixed by this fix for #1772.

Closing two bugs with one patch, nice work Peter!

comment:7 Changed 3 months ago by sjamaan

hm, that makes no sense; that fix should just have removed old duplicates...

comment:8 Changed 3 months ago by sjamaan

Resolution: fixed
Status: closedreopened

Asked reporter to check, but the bug is still there. Maybe my reproduce case is too simple?

comment:9 Changed 3 months ago by sjamaan

Ah, bug is fixed after all. However, I'll leave this ticket open until we've added the regression test.

comment:10 in reply to:  9 Changed 2 months ago by evhan

Resolution: fixed
Status: reopenedclosed

Ah, bug is fixed after all. However, I'll leave this ticket open until we've added the regression test.

That's been added in commit de762521. Closing for real this time!

Note: See TracTickets for help on using tickets.