[
https://issues.apache.org/jira/browse/GROOVY-11744?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18133813#comment-18133813
]
ASF GitHub Bot commented on GROOVY-11744:
-----------------------------------------
daniellansun opened a new pull request, #3073:
URL: https://github.com/apache/groovy/pull/3073
## Summary
Unnamed `_` placeholders in multi-assignment, closures, and lambdas no
longer overwrite a real variable named `_`.
- A single `_` remains a normal variable.
- Later forms such as `(_, y, _) = ...` still update an existing `_` when
that name is already in scope.
- On current master, reading an empty-placeholder `_` already throws
`MissingPropertyException`; that behavior is left unchanged.
## JIRA
https://issues.apache.org/jira/browse/GROOVY-11744
> 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
> 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)