Opened 2 weeks ago

Last modified 2 days ago

#1771 reopened defect

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,


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

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


((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 (9)

comment:1 Changed 2 weeks 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 2 weeks ago by sjamaan

Description: modified (diff)
Milestone: someday5.3

comment:3 Changed 2 weeks 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 ./ ...
; loading ./ ...
#;2> (define a 1)

Error: wrong define!
Last edited 2 weeks ago by sjamaan (previous) (diff)

comment:4 Changed 2 weeks 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 ./ ...
#;2> (display "hi\n")

comment:5 Changed 2 days ago by evhan

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

comment:6 Changed 2 days 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 2 days ago by sjamaan

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

comment:8 Changed 2 days 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 2 days ago by sjamaan

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

Note: See TracTickets for help on using tickets.