MessageNode.st
changeset 2028 a9b5ec797153
parent 1994 4094e1eb3399
child 2096 b993f62fab49
--- a/MessageNode.st	Wed Mar 21 14:23:48 2007 +0100
+++ b/MessageNode.st	Wed Mar 28 14:13:51 2007 +0200
@@ -482,7 +482,7 @@
 !
 
 plausibilityCheck
-    |rec arg1 arg2 arg1Value operand msg|
+    |rec arg1 arg1Value operand msg|
 
     (argArray size > 0) ifTrue:[
         arg1 := argArray at:1
@@ -541,19 +541,31 @@
      (...) whileTrue:[
     "
     ((selector == #whileTrue:) or:[selector == #whileFalse:]) ifTrue:[
-        receiver isBlock ifFalse:[
-            "
-             only warn, if code was originally parenthized
-            "
-            receiver parenthesized ifTrue:[
-                ^ 'will fail at runtime, if receiver of ' , selector , ' does not evaluate to a block or respond reasonable to #value'
-            ]
+        (receiver isBlock not and:[ receiver parenthesized ]) ifTrue:[
+            "/ only warn, if code was originally parenthized
+            ^ 'will fail at runtime, if receiver of ' , selector , ' does not evaluate to a block or respond reasonable to #value'
         ].
         arg1 isBlock ifFalse:[
             ^ 'will fail at runtime, if argument to ' , selector , ' does not evaluate to a block or respond reasonable to #value'
         ].
     ].
 
+    "
+     [...] ensure:[...]
+    "
+    ((selector == #ensure:) or:[(selector == #ifCurtailed:)]) ifTrue:[
+        (receiver isBlock not and:[ receiver parenthesized ]) ifTrue:[
+            "/ only warn, if code was originally parenthized
+            ^ 'will fail at runtime, if receiver of ' , selector , ' does not evaluate to a block or respond reasonable to #value'
+        ].
+        (arg1 isBlock not and:[ arg1 parenthesized ]) ifTrue:[
+            ^ 'will fail at runtime, if receiver of ' , selector , ' does not evaluate to a block or respond reasonable to #value'
+        ].
+        (arg1 isBlock and:[arg1 isEmptyBlock]) ifTrue:[
+            ^ 'useless ensure (empty block)'
+        ].
+    ].
+
     argArray size > 0 ifTrue:[
         "/ check for a beginners error (using super as arg)
         "/ as in (something ? super) foo
@@ -572,7 +584,7 @@
 
     ^ nil
 
-    "Modified: / 16.7.1998 / 20:29:53 / cg"
+    "Modified: / 28-03-2007 / 14:14:28 / cg"
 ! !
 
 !MessageNode methodsFor:'code generation'!
@@ -2862,5 +2874,5 @@
 !MessageNode class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libcomp/MessageNode.st,v 1.160 2007-03-05 12:34:11 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libcomp/MessageNode.st,v 1.161 2007-03-28 12:13:51 cg Exp $'
 ! !