The primitive for Namespace class>>#current: appears to ignore its
argument if it is not a Dictionary or Class.  Perhaps the Smalltalk
code that follows it should do the same, or signal an error of some
kind, if aNamespaceOrClass is not in fact a BindingDictionary (or
Dictionary) or Class?
Yep, as in the attached patch.

Paolo
--- orig/kernel/Builtins.st
+++ mod/kernel/Builtins.st
@@ -2585,10 +2585,18 @@ current: aNamespaceOrClass
     "Set the current namespace to be aNamespace or, if it is a class,
      its class pool (the Dictionary that holds class variables)."
     "The primitive call is needed to inform the compiler"
+    | namespace |
     <primitive: VMpr_Namespace_setCurrent>
-    Current := aNamespaceOrClass isClass
+    namespace := aNamespaceOrClass isClass
        ifTrue: [ aNamespaceOrClass classPool ]
        ifFalse: [ aNamespaceOrClass ].
+
+    (namespace isKindOf: Dictionary)
+       ifTrue: [ Current := namespace ]
+       ifFalse: [
+           SystemExceptions.WrongClass
+               signalOn: aNamespaceOrClass
+               mustBe: { Dictionary. Class } ].
 ! !
 
 
--- orig/kernel/AnsiExcept.st
+++ mod/kernel/AnsiExcept.st
@@ -1083,14 +1083,16 @@ validClassesString
     "Answer the list of classes whose instances would have been valid,
     formatted as a string."
     ^String streamContents: [ :str |
-       validClasses keysAndValuesDo: [ :idx :binding |
+       validClasses keysAndValuesDo: [ :idx :classOrBinding |
            | name class |
            idx > 1 ifTrue: [
                idx = validClasses size
                    ifFalse: [ str nextPutAll: ', ' ]
                    ifTrue: [ str nextPutAll: ' or ' ]
            ].
-           class := binding value.
+           class := classOrBinding isClass
+               ifTrue: [ classOrBinding ]
+               ifFalse: [ classOrBinding value ].
            name := class nameIn: Namespace current.
            name first isVowel
                ifTrue: [ str nextPutAll: 'an ' ]
_______________________________________________
help-smalltalk mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/help-smalltalk

Reply via email to