daniellansun commented on code in PR #2172:
URL: https://github.com/apache/groovy/pull/2172#discussion_r2029274400


##########
subprojects/groovy-groovysh/src/test/groovy/org/apache/groovy/groovysh/GroovyshTest.groovy:
##########
@@ -392,17 +394,34 @@ class GroovyshInterpreterModeTest extends GroovyshTest {
         }
     }
 
+    // groovy:000> int x = 3
+    // ===> 3
+    // groovy:000> x
+    // Unknown property: x
+    // groovy:000> x = 3
+    // ===> 3
+    // groovy:000> x
+    // ===> 3
+    // groovy:000>
     void testBoundVar() {
         Groovysh groovysh = createGroovysh()
 
-        groovysh.execute('int x = 3')
+        groovysh.execute('x = 3')
         assert mockOut.toString().length() > 0
         assert ' 3\n' == mockOut.toString().normalize()[-3..-1]
         groovysh.execute('x')
         assert mockOut.toString().length() > 0
         assert ' 3\n' == mockOut.toString().normalize()[-3..-1]
     }
 
+    // collecting variables relies on GROOVY-4721, e.g. accessing variable 
declared in try block is in scope in finally block
+    // but after GROOVY-4721 is fixed, this test will fail, but it is aligned 
with the behavior of the groovySh:
+    // groovy:000> int x, y, z
+    // ===> 0
+    // groovy:000> y
+    // Unknown property: y
+    // groovy:000>
+    @NotYetImplemented

Review Comment:
   
https://github.com/apache/groovy/blob/87390561659f50e5a117bebb697731e8666f97b3/subprojects/groovy-groovysh/src/main/groovy/org/apache/groovy/groovysh/Groovysh.groovy#L294
   
   Groovysh will try to collect variables in the `finally` block, but variables 
declared in `try` block can not be accessed in `finally` after GROOVY-4721 is 
fixed.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscr...@groovy.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to