You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "zhb (JIRA)" <ji...@apache.org> on 2016/10/23 14:29:58 UTC

[jira] [Commented] (GROOVY-7968) A field and a property with the same name aren't flagged as a duplicate

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

zhb commented on GROOVY-7968:
-----------------------------

I'm afraid it's by design. See [https://github.com/apache/groovy/blob/master/src/test/gls/scope/MultipleDefinitionOfSameVariableTest.groovy#L110](https://github.com/apache/groovy/blob/master/src/test/gls/scope/MultipleDefinitionOfSameVariableTest.groovy#L110)

> A field and a property with the same name aren't flagged as a duplicate
> -----------------------------------------------------------------------
>
>                 Key: GROOVY-7968
>                 URL: https://issues.apache.org/jira/browse/GROOVY-7968
>             Project: Groovy
>          Issue Type: Bug
>            Reporter: Paul King
>
> Two fields or two properties with the same name cause compilation to fail but the following script passes (showing that the backing field has precedence) but should not compile:
> {code}
> class HasDate {
>   Date d = new Date()
>   private Date d = null
> }
> assert !new HasDate().d
> {code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)