--- smalltalk-2.3.1/compiler/STSymTable.st 2006-02-05 12:41:19.000000000 -0600 +++ smalltalk/compiler/STSymTable.st 2006-12-31 15:50:15.000000000 -0600 @@ -118,7 +118,7 @@ Object subclass: #STSymbolTable - instanceVariableNames: 'variables tempCount litTable pools instVars environment scopes' + instanceVariableNames: 'variables tempCount litTable pools instVars environment scopes scopeVariables' classVariableNames: 'UseUndeclared' poolDictionaries: '' category: 'System-Compiler' @@ -202,18 +202,21 @@ ! declareTemporary: tempName canStore: canStore for: stCompiler - | ok symbol | + | symbol | symbol := tempName asSymbol. - ok := variables includesKey: symbol. + (variables includesKey: symbol) + ifTrue: [(variables at: symbol) scope < scopes size + ifTrue: [stCompiler compileWarning: + ('variable ''%1'' shadows another' + bindWith: tempName)] + ifFalse: [^stCompiler compileError: + 'duplicate variable name ', tempName]]. variables at: symbol put: (STVariable id: tempCount scope: scopes size canStore: canStore ). - ok ifFalse: [ - stCompiler compileWarning: 'duplicate variable name ', tempName - ]. tempCount := tempCount + 1. ^tempCount - 1 ! @@ -221,12 +224,15 @@ scopeEnter scopes add: tempCount. tempCount := 0. + scopeVariables add: variables. + variables := variables copy. ! scopeLeave "Answer whether we are in a `clean' scope (no return from method, no references to variable in an outer scope)." tempCount := scopes removeLast. + variables := scopeVariables removeLast. ! undeclareTemporary: tempName @@ -354,6 +361,7 @@ variables := Dictionary new: 5. litTable := STLiteralsTable new: 13. instVars := Dictionary new: 7. + scopeVariables := OrderedCollection new: 5. scopes := OrderedCollection new: 5. pools := IdentitySet new: 7. tempCount := 0.