paulk-asert commented on code in PR #2172: URL: https://github.com/apache/groovy/pull/2172#discussion_r2030997973
########## 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: I added the change to StatementWriter and changed groovysh to just have the "variableBlocks" execute directly after "current" (i.e. just removed the try...finally) then interpreterMode still seemed to work. The current test suite and the new tests all passed. There could be variations that we don't have coverage for in our test suite that may become broken with that change. -- 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