--- a/Parser.st Tue Jun 10 17:09:54 2014 +0200
+++ b/Parser.st Tue Jun 10 17:21:08 2014 +0200
@@ -2869,6 +2869,20 @@
"Created: / 17-11-2001 / 10:23:47 / cg"
"Modified: / 07-07-2010 / 15:48:24 / cg"
+!
+
+isPossiblyUninitializedLocal:aNode
+ |varName|
+
+ aNode isLocalVariable ifFalse:[^ false].
+ varName := aNode name.
+ (modifiedLocalVars notNil and:[(modifiedLocalVars includes:varName)]) ifTrue:[^ false].
+ hasPrimitiveCode ifTrue:[^ false]. "/ because I do not look into it, yet
+ ((aNode isMethodVariable and:[currentBlock isNil])
+ or:[ aNode isBlockVariable and:[aNode block == currentBlock]]) ifFalse:[^ false].
+ (alreadyWarnedUninitializedVars notNil
+ and:[(alreadyWarnedUninitializedVars includes:varName)]) ifTrue:[^ false].
+ ^ true.
! !
!Parser methodsFor:'dummy-syntax detection'!
@@ -4191,16 +4205,20 @@
].
].
].
- ] ifFalse:[(receiver isMethodVariable and:[receiver token type isNil]) ifTrue:[
- "if it is an uninitialized variable ..."
- ((modifiedLocalVars isNil or:[(modifiedLocalVars includes:receiver name) not])
- and:[hasPrimitiveCode not
- and:[currentBlock isNil
- and:[alreadyWarnedUninitializedVars isNil
- or:[(alreadyWarnedUninitializedVars includes:receiver name) not]]]])
- ifTrue:[
+ ] ifFalse:[
+ (self isPossiblyUninitializedLocal:receiver) ifTrue:[
+"/ (receiver isLocal and:[receiver token type isNil]) ifTrue:[
+ "if it is an uninitialized variable ..."
+
+"/ ((modifiedLocalVars isNil or:[(modifiedLocalVars includes:receiver name) not])
+"/ and:[hasPrimitiveCode not
+"/ and:[((receiver isMethodVariable and:[currentBlock isNil])
+"/ or:[ receiver isBlockVariable and:[receiver block == currentBlock]])
+"/ and:[alreadyWarnedUninitializedVars isNil
+"/ or:[(alreadyWarnedUninitializedVars includes:receiver name) not]]]])
+"/ ifTrue:[
((#(at: at:put: basicAt: basicAt:put:) includes:selectorSymbol)
- or:[(nil respondsTo:selectorSymbol) not])ifTrue:[
+ or:[(nil respondsTo:selectorSymbol) not]) ifTrue:[
"/ avoid trouble in miniTalk
"/ during bootstrap
nm := receiver name.
@@ -4213,7 +4231,7 @@
].
alreadyWarnedUninitializedVars add:receiver name
]
- ]
+"/ ]
] ifFalse:[
(err notNil and:[selClass notNil]) ifTrue:[
((selClass == Boolean)
@@ -6575,6 +6593,12 @@
expr lineNumber:lno.
expr selectorPosition:pos1.
+ (self isPossiblyUninitializedLocal:arg) ifTrue:[
+ self
+ warning:'"',arg name,'" is uninitialized here (always nil)'
+ position:(arg startPosition) to:(arg endPosition).
+ ].
+
self checkPlausibilityOf:expr from:pos1 to:pos2.
parseForCode ifFalse:[
self rememberSelectorUsed:sel receiver:receiver
@@ -7079,6 +7103,14 @@
args := args copyWith:arg.
].
+ args do:[:eachArg |
+ (self isPossiblyUninitializedLocal:eachArg) ifTrue:[
+ self
+ warning:'"',eachArg name,'" is uninitialized here (always nil)'
+ position:(eachArg startPosition) to:(eachArg endPosition).
+ ].
+ ].
+
selectorPartPositions do:[:p |
self markSelector:sel from:p start to:p stop receiverNode:receiver.
].
@@ -8360,9 +8392,7 @@
"/ attention: may have been optimized (Character return -> const!!
expr isMessage ifTrue:[
expr selectorPosition:pos.
-
sel := self selectorCheck:sel for:receiver position:pos to:pos2.
-
expr selector:sel. "/ update possibly changed selector.
].
@@ -11904,11 +11934,11 @@
!Parser class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libcomp/Parser.st,v 1.832 2014-06-10 14:29:02 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libcomp/Parser.st,v 1.833 2014-06-10 15:21:08 cg Exp $'
!
version_CVS
- ^ '$Header: /cvs/stx/stx/libcomp/Parser.st,v 1.832 2014-06-10 14:29:02 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libcomp/Parser.st,v 1.833 2014-06-10 15:21:08 cg Exp $'
!
version_SVN