Commit 3e185d97 authored by mevenson@1c010e3e-69d0-11dd-93a8-456734b0d56f's avatar mevenson@1c010e3e-69d0-11dd-93a8-456734b0d56f
Browse files

Fix UNEXPORT to work on symbols from foreign packages.

No longer check that the symbols which are the target of UNEXPORT are
accessible.  Such symbols may be present in a foreign package as they
may have been part of a USE clause for which the original symbol has
subsequently made internal in its home package by a previous UNEXPORT
operation.

Fixes #311.
parent 800456b8
......@@ -560,28 +560,16 @@ public final class Package extends LispObject implements java.io.Serializable
public synchronized void unexport(final Symbol symbol)
{
if (symbol.getPackage() == this) {
if (externalSymbols.get(symbol.name.toString()) == symbol) {
externalSymbols.remove(symbol.name.toString());
internalSymbols.put(symbol.name.toString(), symbol);
}
} else {
// Signal an error if symbol is not accessible.
if (useList instanceof Cons) {
LispObject usedPackages = useList;
while (usedPackages != NIL) {
Package pkg = (Package) usedPackages.car();
if (pkg.findExternalSymbol(symbol.name) == symbol)
return; // OK.
usedPackages = usedPackages.cdr();
}
}
StringBuilder sb = new StringBuilder("The symbol ");
sb.append(symbol.getQualifiedName());
sb.append(" is not accessible in package ");
sb.append(name);
error(new PackageError(sb.toString()));
}
if (externalSymbols.get(symbol.name.toString()) == symbol) {
externalSymbols.remove(symbol.name.toString());
internalSymbols.put(symbol.name.toString(), symbol);
} else if (!(internalSymbols.get(symbol.name.toString()) == symbol)) {
StringBuilder sb = new StringBuilder("The symbol ");
sb.append(symbol.getQualifiedName());
sb.append(" is not accessible in package ");
sb.append(name);
error(new PackageError(sb.toString()));
}
}
public synchronized void shadow(final String symbolName)
......
......@@ -141,3 +141,21 @@ nil)
'(a .?0))
(A . #\Null))
;;; http://trac.common-lisp.net/armedbear/ticket/311
(deftest bugs.export.1
(let ((a (symbol-name (gensym "PACKAGE-")))
(b (symbol-name (gensym "PACKAGE-")))
result)
(make-package a)
(intern "FOO" a)
(export (find-symbol "FOO" a) a)
(make-package b :use (list a))
(export (find-symbol "FOO" b) b)
(unexport (find-symbol "FOO" a) a)
(setf result (unexport (find-symbol "FOO" b) b))
(delete-package a)
(delete-package b)
result)
t)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment