Fix in Parser>>#errorMessageForUndefined:
Make sure a symbol is passed to Namespace>>at:/Smalltalk>>at:. Short-circuit
tests when no Symbol instance exists (to avoid useless symbol creation)
--- a/Parser.st Tue Oct 21 20:49:38 2014 +0200
+++ b/Parser.st Tue Oct 28 13:50:59 2014 +0100
@@ -4446,29 +4446,33 @@
"Created: / 28-02-2012 / 14:44:31 / cg"
!
-errorMessageForUndefined:aName
- |idx implementors spaces nameBold|
-
- nameBold := aName allBold.
+errorMessageForUndefined:variableName
+ "Return a proper method for undefined variable named `variableName`"
+
+ |idx implementors spaces nameBold variableNameAsSymbol |
+
+ nameBold := variableName allBold.
classToCompileFor notNil ifTrue:[
"/ is it an instance-variable marked inaccessable ?
- idx := (self classesInstVarNames) indexOf:(aName , '*') startingAt:1.
+ idx := (self classesInstVarNames) indexOf:(variableName , '*') startingAt:1.
idx ~~ 0 ifTrue:[
^ '''%1'' is a hidden instvar (not accessable from ST-code)' bindWith:nameBold.
].
"/ is it an instance variable, while evaluateing for the class ?
classToCompileFor isMeta ifTrue:[
- (classToCompileFor soleInstance allInstVarNames includes:aName) ifTrue:[
+ (classToCompileFor soleInstance allInstVarNames includes:variableName) ifTrue:[
^ '''%1'' is an instvar\(hint: you are evaluating/compiling in the classes context)' bindWith:nameBold.
]
]
].
- self isDoIt ifTrue:[
+ variableNameAsSymbol := variableName asSymbolIfInterned.
+
+ (variableNameAsSymbol notNil and:[self isDoIt]) ifTrue:[
SystemBrowser notNil ifTrue:[
implementors := SystemBrowser
- findImplementorsOf:aName
+ findImplementorsOf:variableName
in:(Smalltalk allClasses)
ignoreCase:false.
implementors size > 0 ifTrue:[
@@ -4477,23 +4481,27 @@
bindWith:nameBold
with:implementors first mclass name allBold
].
- ^ '''%1'' is undefined but known as a message selector.\(hint: did you forget to specify or select the receiver ?)' bindWith:aName allBold.
+ ^ '''%1'' is undefined but known as a message selector.\(hint: did you forget to specify or select the receiver ?)' bindWith:variableName allBold.
].
].
].
peekChar == $: ifTrue:[
^ 'NameSpace "%1" is undefined' bindWith:nameBold.
].
- spaces := NameSpace allNameSpaces select:[:ns |ns includesKey:aName].
- spaces notEmpty ifTrue:[
- spaces size == 1 ifTrue:[
- ^ '"%1" is undefined\(but found in namespace "%2")'
- bindWith:nameBold with:spaces first name.
- ].
- ^ '"%1" is undefined\(but found in "%2" and %3 other namespaces)'
- bindWith:nameBold with:spaces first name with:spaces size-1.
+ variableNameAsSymbol notNil ifTrue:[
+ spaces := NameSpace allNameSpaces select:[:ns |ns includesKey:variableNameAsSymbol].
+ spaces notEmpty ifTrue:[
+ spaces size == 1 ifTrue:[
+ ^ '"%1" is undefined\(but found in namespace "%2")'
+ bindWith:nameBold with:spaces first name.
+ ].
+ ^ '"%1" is undefined\(but found in "%2" and %3 other namespaces)'
+ bindWith:nameBold with:spaces first name with:spaces size-1.
+ ].
].
^ '"%1" is undefined' bindWith:nameBold.
+
+ "Modified: / 28-10-2014 / 12:45:32 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
exitWith:something
@@ -5295,6 +5303,7 @@
selector := aParser selector.
! !
+
!Parser methodsFor:'obsolete'!
correctByDeleting
@@ -11979,11 +11988,11 @@
!Parser class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libcomp/Parser.st,v 1.843 2014-09-23 20:28:52 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libcomp/Parser.st,v 1.844 2014-10-28 12:50:59 vrany Exp $'
!
version_CVS
- ^ '$Header: /cvs/stx/stx/libcomp/Parser.st,v 1.843 2014-09-23 20:28:52 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libcomp/Parser.st,v 1.844 2014-10-28 12:50:59 vrany Exp $'
!
version_SVN