Opened 8 years ago

Last modified 8 years ago

#940 new enhancement

CCL should warn when attempting to redefine a package to have fewer exported symbols

Reported by: fare Owned by:
Priority: minor Milestone:
Component: Compiler Version: trunk
Keywords: ITA Cc:


Ethan H. Schwartz 2010-06-24 15:50:22 EDT

If you define a package twice, and the second definition omits exported symbols that were exported in the first package definition, CCL silently leaves the symbols exported from the package.

Welcome to Clozure Common Lisp Version 1.4-dev  (LinuxX8664)!
? (defpackage foo (:use :common-lisp) (:export #:myfoo #:mybar))
#<Package "FOO">
? (defpackage foo (:use :common-lisp) (:export #:myfoo))
#<Package "FOO">
? 'foo:myfoo
? 'foo:mybar

It would be nice if the second defpackage warned. SBCL does this:

* (defpackage foo (:use :common-lisp) (:export #:myfoo #:mybar))
* (defpackage foo (:use :common-lisp) (:export #:myfoo))
WARNING: FOO also exports the following symbols:
See also:
  The ANSI Standard, Macro DEFPACKAGE

* 'foo:myfoo
* 'foo:mybar

We run into this issue in QRes because we sometimes define packages multiple times in order to avoid dependency problems. It's also a problem if you try to do dirty compilation after de-exporting a symbol, because the symbol won't actually get de-exported. A compiler warning would help remind you not to rely on dirty compilation in this case. :)

PS: was ITA bug 82521

Change History (1)

comment:1 Changed 8 years ago by gz

  • Keywords ITA added
Note: See TracTickets for help on using tickets.