--- a/Parser.st Tue Oct 18 16:26:49 2005 +0200
+++ b/Parser.st Tue Oct 18 18:05:08 2005 +0200
@@ -3568,17 +3568,15 @@
warnUnused:aNameCollection
"report an unused method variable"
- |s msg answer|
+ |msg answer|
(ignoreErrors not
and:[ignoreWarnings not
and:[parserFlags warnUnusedVars]]) ifTrue:[
- s := '' writeStream.
- s nextPutAll:'Unused method variable(s): '.
+ msg := 'Unused method variable(s): '.
aNameCollection asSortedCollection do:[:name|
- s nextPutAll:' '; nextPutAll:name allBold.
- ].
- msg := s contents.
+ msg := msg , (' "',name allBold,'"').
+ ].
(requestor isNil or:[requestor isStream]) ifTrue:[
self showErrorMessage:('Warning: ', msg) position:nil.
@@ -4010,7 +4008,7 @@
(tokenType ~~ #EOF) ifTrue:[
"/ just for the nicer error message
(#(Self Nil True False Super Here) includes:tokenType) ifTrue:[
- self parseError:tokenName , ' unexpected (missing ''.'' or '':'' before ' , tokenName , ' ?)'
+ self parseError:'"',tokenName allBold,'" unexpected (missing ''.'' or '':'' before ' , tokenName , ' ?)'
position:tokenPosition to:(tokenPosition + tokenName size - 1)
] ifFalse:[
tokenType isCharacter ifTrue:[
@@ -4272,7 +4270,7 @@
(tokenType == $|) ifTrue:[
"memorize position for declaration in correction"
- localVarDefPosition := tokenPosition.
+ localVarDefPosition := Array with:tokenPosition with:nil.
self nextToken.
pos := tokenPosition.
[tokenType == #Identifier] whileTrue:[
@@ -4291,7 +4289,7 @@
self markBadIdentifierFrom:tokenPosition to:pos2.
] ifFalse:[
self
- parseError:'redefinition of ''' , tokenName , ''' in local variables'
+ parseError:'redefinition of ''' , tokenName , ''' in local variables.'
position:tokenPosition to:pos2.
]
] ifFalse:[
@@ -4300,13 +4298,23 @@
]
].
- methodArgNames notNil ifTrue:[
- (methodArgNames includes:tokenName) ifTrue:[
- self
- warning:'local variable ''' , tokenName , ''' hides argument.'
- position:tokenPosition to:pos2
- ]
+ parserFlags warnHiddenVariables ifTrue:[
+ methodArgNames notNil ifTrue:[
+ (methodArgNames includes:tokenName) ifTrue:[
+ self
+ warning:'local variable "' , tokenName allBold , '" hides method argument.'
+ position:tokenPosition to:pos2
+ ]
+ ].
+ classToCompileFor notNil ifTrue:[
+ (self classesInstVarNames includes:tokenName) ifTrue:[
+ self
+ warning:'local variable "' , tokenName allBold , '" hides instance variable.'
+ position:tokenPosition to:pos2
+ ]
+ ].
].
+
self nextToken.
classHint := nil.
@@ -4334,7 +4342,7 @@
(tokenType ~~ $|) ifTrue:[
(#(True False Self Nil Super ThisContext) includes:tokenType) ifTrue:[
- msg := 'Reserved keyword in local var declaration'.
+ msg := 'reserved keyword "',tokenName allBold,'" in local var declaration'.
pos2 := tokenPosition + tokenName size - 1.
self markBadIdentifierFrom:tokenPosition to:pos2.
] ifFalse:[
@@ -4344,7 +4352,7 @@
self syntaxError:msg position:tokenPosition to:pos2.
^ #Error
].
- localVarDefPosition := Array with:localVarDefPosition with:tokenPosition.
+ localVarDefPosition at:2 put:tokenPosition.
self nextToken
].
@@ -4403,6 +4411,15 @@
methodArgs := methodArgs copyWith:arg.
methodArgNames := methodArgNames copyWith:tokenName
].
+ parserFlags warnHiddenVariables ifTrue:[
+ classToCompileFor notNil ifTrue:[
+ (self classesInstVarNames includes:tokenName) ifTrue:[
+ self
+ warning:'argument "' , tokenName allBold , '" hides instance variable.'
+ position:tokenPosition to:pos2
+ ]
+ ].
+ ].
self nextToken.
"/ ((tokenType == #BinaryOperator) and:[token = '#']) ifTrue:[
"/ self nextToken.
@@ -5911,7 +5928,7 @@
!
primary_identifier
- "parse a false primary; return a node-tree, or raise an Error."
+ "parse a primary; return a node-tree, or raise an Error."
|pos1 pos2 expr varName rawName var globlName nameSpace nameSpaceGlobal
t cls lnr node holder autoHow assignmentAllowed|
@@ -7981,7 +7998,7 @@
!Parser class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libcomp/Parser.st,v 1.468 2005-10-18 14:26:30 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libcomp/Parser.st,v 1.469 2005-10-18 16:05:08 cg Exp $'
! !
Parser initialize!
--- a/ParserFlags.st Tue Oct 18 16:26:49 2005 +0200
+++ b/ParserFlags.st Tue Oct 18 18:05:08 2005 +0200
@@ -19,12 +19,12 @@
warnUnderscoreInIdentifier warnOldStyleAssignment
warnCommonMistakes warnSTXNameSpaceUse
warnPossibleIncompatibilities warnDollarInIdentifier
- warnAboutVariableNameConventions warnAboutWrongVariableNames
- allowLiteralNameSpaceSymbols allowUnderscoreInIdentifier
- allowDollarInIdentifier allowOldStyleAssignment
- allowSqueakExtensions allowDolphinExtensions
- allowExtendedBinarySelectors allowQualifiedNames
- allowFunctionCallSyntaxForBlockEvaluation
+ warnHiddenVariables warnAboutVariableNameConventions
+ warnAboutWrongVariableNames allowLiteralNameSpaceSymbols
+ allowUnderscoreInIdentifier allowDollarInIdentifier
+ allowOldStyleAssignment allowSqueakExtensions
+ allowDolphinExtensions allowExtendedBinarySelectors
+ allowQualifiedNames allowFunctionCallSyntaxForBlockEvaluation
allowLocalVariableDeclarationWithInitializerExpression
allowDomainVariables allowArrayIndexSyntaxExtension
allowReservedWordsAsSelectors allowVariableReferences
@@ -35,7 +35,8 @@
WarnAboutWrongVariableNames WarnAboutVariableNameConventions
WarnSTXSpecials WarnOldStyleAssignment WarnUnderscoreInIdentifier
WarnCommonMistakes WarnPossibleIncompatibilities
- WarnDollarInIdentifier Warnings AllowUnderscoreInIdentifier
+ WarnDollarInIdentifier WarnHiddenVariables Warnings
+ AllowUnderscoreInIdentifier
AllowFunctionCallSyntaxForBlockEvaluation AllowLazyValueExtension
AllowVariableReferences AllowReservedWordsAsSelectors
AllowLocalVariableDeclarationWithInitializerExpression
@@ -532,6 +533,7 @@
WarnOldStyleAssignment := true.
WarnCommonMistakes := true.
WarnPossibleIncompatibilities := false.
+ WarnHiddenVariables := true.
AllowReservedWordsAsSelectors := false.
AllowUnderscoreInIdentifier := true. "/ underscores in identifiers
@@ -766,6 +768,14 @@
warnDollarInIdentifier := aBoolean.
!
+warnHiddenVariables
+ ^ warnHiddenVariables
+!
+
+warnHiddenVariables:aBoolean
+ warnHiddenVariables := aBoolean.
+!
+
warnOldStyleAssignment
^ warnOldStyleAssignment
!
@@ -854,6 +864,7 @@
warnPossibleIncompatibilities := WarnPossibleIncompatibilities.
warnAboutVariableNameConventions := WarnAboutVariableNameConventions.
warnAboutWrongVariableNames := WarnAboutWrongVariableNames.
+ warnHiddenVariables := WarnHiddenVariables.
allowUnderscoreInIdentifier := AllowUnderscoreInIdentifier.
allowDollarInIdentifier := AllowDollarInIdentifier.
@@ -886,7 +897,7 @@
!ParserFlags class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libcomp/ParserFlags.st,v 1.1 2005-10-18 14:24:22 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libcomp/ParserFlags.st,v 1.2 2005-10-18 16:04:53 cg Exp $'
! !
ParserFlags initialize!