Summary
Except specificier in imports
Metadata
- Id: 4235d8b5008848ed66118a8f99ffddae6486dcc4
- Trac id: 1771
- Type: defect
- Reporter: Idiomdrottning
- Owner:
- Cc:
- Status: closed
- Component: unknown
- Estimated difficulty:
- Resolution: fixed
- Priority: major
- Milestone: 5.3
- Version:
- Changetime: 2021-08-06 01:48:11 UTC
- Created: 2021-07-16 13:01:44 UTC
- Keywords:
Description
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))
Changes and comments
[2021-07-16 13:13:31 UTC] sjamaan wrote:
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.
[2021-07-16 13:17:12 UTC] sjamaan changed description
[2021-07-16 13:17:12 UTC] sjamaan changed milestone from someday to 5.3
[2021-07-16 13:23:55 UTC] sjamaan wrote:
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!
[2021-07-16 13:23:55 UTC] sjamaan wrote:
1626434715499864
[2021-07-16 13:32:57 UTC] sjamaan wrote:
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
[2021-07-30 06:25:34 UTC] evhan wrote:
I can't reproduce this on master, with or without the patch for #1757. What am I missing?
[2021-07-30 06:58:12 UTC] evhan wrote:
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!
[2021-07-30 06:58:12 UTC] evhan changed status from new to closed
[2021-07-30 06:58:12 UTC] evhan set resolution to fixed
[2021-07-30 07:40:20 UTC] sjamaan wrote:
hm, that makes no sense; that fix should just have removed old duplicates...
[2021-07-30 08:32:39 UTC] sjamaan changed status from closed to reopened
[2021-07-30 08:32:39 UTC] sjamaan removed resolution fixed
[2021-07-30 08:32:39 UTC] sjamaan wrote:
Asked reporter to check, but the bug is still there. Maybe my reproduce case is too simple?
[2021-07-30 11:44:16 UTC] sjamaan wrote:
Ah, bug is fixed after all. However, I'll leave this ticket open until we've added the regression test.
[2021-08-06 01:48:11 UTC] evhan changed status from reopened to closed
[2021-08-06 01:48:11 UTC] evhan set resolution to fixed
[2021-08-06 01:48:11 UTC] evhan wrote:
> 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!