[ 
https://issues.apache.org/jira/browse/GROOVY-11744?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18134249#comment-18134249
 ] 

ASF GitHub Bot commented on GROOVY-11744:
-----------------------------------------

daniellansun commented on PR #3073:
URL: https://github.com/apache/groovy/pull/3073#issuecomment-6499242702

   Thanks Paul — I went through your table and #3075 carefully.
   
   You're right that 6.0.0 already changed the 5.x behaviour (via GROOVY-12242) 
without a COMPATIBILITY note, and that treating a repeated `_` as a different 
kind of binding makes the single- vs multi-assignment story harder than it 
needs to be. I'd rather keep one rule: `_` stays an ordinary variable that may 
be declared again, with each declaration replacing the earlier one.
   
   So I'm happy to go with #3075 and will close this PR in favour of yours. 
Thanks for digging into the regression and putting up the smaller alternative.




> Unnamed variables are actually used
> -----------------------------------
>
>                 Key: GROOVY-11744
>                 URL: https://issues.apache.org/jira/browse/GROOVY-11744
>             Project: Groovy
>          Issue Type: Bug
>            Reporter: Georgii Ustinov
>            Assignee: Daniel Sun
>            Priority: Major
>
> I am currently implementing Groovy 5 support inside Intellij IDEA and 
> encountered the following behaviour. Consider the following code:
> {code:java}
> package org.example.demo
> static void main(String[] args) {
>     def _ = 1
>     def (_, _) = [2, 3]
>     println _
> } {code}
> I expected that it will print 1, since variable declaration contains only 
> unnamed variables.
> Actually it prints 3. The same behaviour can be encountered here:
> {code:java}
> def _ = 1
> def x = (_, _) -> {
> println(_)
> }
> x(2, 3){code}
> I beileve this is a bug. 



--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

Reply via email to