#FEATURE by cg
authorClaus Gittinger <cg@exept.de>
Wed, 12 Oct 2016 18:01:37 +0200
changeset 4015 527fa2959e31
parent 4014 b7fae905c8f4
child 4016 c288a77d5952
#FEATURE by cg class: Parser changed: #blockBody #parseMethodBodyVarSpec if warnPossibleIncompatibility is set, warn about empty local var decls.
Parser.st
--- a/Parser.st	Wed Oct 12 16:05:31 2016 +0200
+++ b/Parser.st	Wed Oct 12 18:01:37 2016 +0200
@@ -5532,7 +5532,7 @@
 blockBody
     "parse a currentBlock's block-body; return a node-tree, nil or #Error"
 
-    |prevFlags stats var vars lno pos2|
+    |prevFlags stats var vars lno pos2 barPos1|
 
     lno := tokenLineNr.
 
@@ -5541,7 +5541,8 @@
         self parsePrimitiveOrResourceSpecOrEmpty.
     ].
 
-    (tokenType == $| ) ifTrue:[
+    (tokenType == $| ) ifTrue:[        
+        barPos1 := tokenPosition.
         self nextToken.
         [tokenType == $|] whileFalse:[
             (tokenType == #Identifier) ifFalse:[
@@ -5582,7 +5583,16 @@
                 ].
             ].
         ].
-        self nextToken
+        vars isEmptyOrNil ifTrue:[
+            parserFlags warnPossibleIncompatibilities == true ifTrue:[
+                self
+                    warning:('empty local variable list (possible incompatibility)')
+                    doNotShowAgainAction:[ parserFlags warnPossibleIncompatibilities:false.
+                                           ParserFlags warnPossibleIncompatibilities:false]
+                    position:barPos1 to:source position.
+            ]    
+        ].    
+        self nextToken.
     ].
     currentBlock variables:vars.
 
@@ -6047,6 +6057,16 @@
             ^ #Error
         ].
         localVarDefPosition at:2 put:tokenPosition.
+        
+        methodVars isEmptyOrNil ifTrue:[
+            parserFlags warnPossibleIncompatibilities == true ifTrue:[
+                self
+                    warning:('empty local variable list (possible incompatibility)')
+                    doNotShowAgainAction:[ parserFlags warnPossibleIncompatibilities:false.
+                                           ParserFlags warnPossibleIncompatibilities:false]
+                    position:(localVarDefPosition first) to:source position.
+            ]    
+        ].    
         self nextToken
     ].