[ https://issues.apache.org/jira/browse/GROOVY-11601?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18004769#comment-18004769 ]
Daniel Sun commented on GROOVY-11601: ------------------------------------- {code:java} package gls.statements import org.junit.jupiter.api.Test import static groovy.test.GroovyAssert.assertScript class ForTest { @Test void testForLoop() { assertScript """ // B for ({ List items2 = []; int i = 3; long j = 70 }(); i < 8; i++, j -= 10) { // note multiple types items2 << i + j } assert items2 == [73, 64, 55, 46, 37] """ } } {code} The above for-loop is not supported in master branch: {code:java} No such property: i for class: TestScript0 groovy.lang.MissingPropertyException: No such property: i for class: TestScript0 at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.unwrap(ScriptBytecodeAdapter.java:69) at org.codehaus.groovy.vmplugin.v8.IndyGuardsFiltersAndSignatures.unwrap(IndyGuardsFiltersAndSignatures.java:163) at org.codehaus.groovy.vmplugin.v8.IndyInterface.fromCache(IndyInterface.java:344) at TestScript0.run(TestScript0.groovy:3) at groovy.lang.GroovyShell.evaluate(GroovyShell.java:489) at groovy.lang.GroovyShell.evaluate(GroovyShell.java:524) at groovy.lang.GroovyShell.evaluate(GroovyShell.java:508) at groovy.test.GroovyAssert.assertScript(GroovyAssert.java:103) at groovy.test.GroovyAssert.assertScript(GroovyAssert.java:93) at org.codehaus.groovy.vmplugin.v8.IndyInterface.fromCache(IndyInterface.java:344) at gls.statements.ForTest.testForLoop(ForTest.groovy:29) at java.base/java.lang.reflect.Method.invoke(Method.java:580) at java.base/java.util.ArrayList.forEach(ArrayList.java:1596) at java.base/java.util.ArrayList.forEach(ArrayList.java:1596) {code} > remove support for expression list in for-each statement > -------------------------------------------------------- > > Key: GROOVY-11601 > URL: https://issues.apache.org/jira/browse/GROOVY-11601 > Project: Groovy > Issue Type: Improvement > Components: parser-antlr4 > Reporter: Eric Milles > Assignee: Eric Milles > Priority: Minor > > The for-each loop supports an arbitrary expression list. Presumably this is > for legacy reasons. Now that multi-variable declaration is supported by > for-each and classic for, it does not seem necessary to support expression > list. I propose to remove it from the parser grammar. -- This message was sent by Atlassian Jira (v8.20.10#820010)